Hi,
So my player has a number of skins, for which I call a trigger to switch ion On Start depending on the scene. I am using Lipsync Portraits with expressions, but is there a way to change the expressions image with a script?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Yes - expressions can be modified by accessing the Char script's expressions List:
Great! Thanks!
Is there a way to switch a cursor set too?
In what context?
You can call the CursorIcon class's ReplaceTexture function to replace its texture, e.g:
To get an API reference to access each of your cursors, right-click each cursor's texture field in the Cursor Manager.
Being a bit of a noob, what would wrap this code in the script? Really appreciate your help (specifically for ReplaceTexture
Just place it in a parameterless public function, i.e.:
Then add it to a new GameObject, make it a prefab, remove from the scene, and use the Object: Call event Action to trigger the prefab's ChangeCursor function when you wish to change the cursor's texture.
so i get this error
Assets/Sleepytime Village/Scripts/ChangeCursor.cs(9,13): error CS0116: A namespace cannot directly contain members such as fields or methods
using
using System.Collections;
using UnityEngine.UI;
using UnityEngine;
using UnityEngine.SceneManagement;
public Texture2D newTexture;
public void ChangeCursor ()
{
AC.KickStarter.cursorManager.pointerIcon.ReplaceTexture (newTexture);
}
i think it might be easier to replace entire cursor manager on scene start - so i could have two cursor managers and choose which one on start of scene, is that possible?
otherwise i was trying to write this, but had errors;
Assets/Sleepytime Village/Scripts/CursorUtils.cs(18,70): error CS1061: 'Texture' does not contain a definition for 'ReplaceTexture' and no accessible extension method 'ReplaceTexture' accepting a first argument of type 'Texture' could be found (are you missing a using directive or an assembly reference?)
using System.Collections;
using UnityEngine.UI;
using UnityEngine;
using UnityEngine.SceneManagement;
public class CursorUtils : MonoBehaviour
{
public Texture2D newTexture;
public int textureIndex;
}
Hi, so I have tried this and it just seems to remove and not replace the cursor (i am using animated cursors (spritesheets)
using UnityEngine;
public class CursorUtils : MonoBehaviour
{
public Texture2D newTexture;
public int textureIndex;
}
Have you assigned the texture in the "New Texture" Inspector field, and does it match the number of animations as your default texture?
Yes they are identical in size and frames
https://www.dropbox.com/sh/vwcll1sczn8x0ep/AAAFHdXntqVhRUIwf5qMvaXBa?dl=0
I am calling the texture from my project and not scene
Your screenshot of your Object: Call event Action crops out an important message box: event parameters cannot be set in the Action.
You must amend your script to store the texture within it's Inspector, so that the function you call needs no parameter. See my example from earlier:
Sorry, so I would put in 'Pointer' (name of .png cursor in project) for example where (newTexture) is in the script? Even though it is dropped in to call event here?
https://www.dropbox.com/sh/vwcll1sczn8x0ep/AAAFHdXntqVhRUIwf5qMvaXBa?dl=0
Yes: again, parameters assigned in the call event Action are ignored.