String Variable Not Changing From Starting Value,
Hi, I have been trying to make a cursor change script for a while now, and even after re-writing the whole script I am still having troubles.
The cursor script is intended to change cursor sprite when called from the card's event system (which i will expand later). The cursor sprites are changing how they should, but the currentCursorState variable will not change, in the editor and debug it remains on normal, as shown in the video, even though it should not be changed.
Is this an issue with how I am assigning the strings? I have changed the string to an int (because I thought it may have something to do with immutability), and the same problem persists.
I mostly just hope that the problem isn't some dumb mistake I have made.....
Here is the error in action:
Here is the Event Trigger System on the Card that is spawned
Here is the script:
public class CursorControlV2 : MonoBehaviour
{
public Texture2D cursorNormal;
public Texture2D cursorDown;
public Texture2D cursorHover;
public Texture2D cursorEnemyHover;
public string currentCursorState;
public CursorMode cursorMode = CursorMode.Auto;
public Vector2 hotSpot;
public bool debugCursorEvents = true;
void Start()
{
hotSpot = new Vector2(9, 4);
QualitySettings.vSyncCount = 0;
CursorNormal();
}
public void CursorHover()
{
if (currentCursorState != "cursorDown")
{
currentCursorState = "cursorHover";
Cursor.SetCursor(cursorHover, hotSpot, cursorMode);
if (debugCursorEvents) { print(currentCursorState); }
}
else
{
if (debugCursorEvents) { print("Attempted hover, but cursor was down"); }
}
if (debugCursorEvents) { print("CursorHover() has been called"); }
}
public void CursorStopHover()
{
if (currentCursorState != "cursorDown")
{
CursorNormal();
}
if (debugCursorEvents) { print("CursorStopHover() has been called"); }
}
public void CursorUp()
{
currentCursorState = "cursorUp";
CursorHover();
}
public void CursorDown()
{
Cursor.SetCursor(cursorDown, hotSpot, cursorMode);
currentCursorState = "cursorDown";
if (debugCursorEvents) { print("CursorDown() has been called"); }
}
public void CursorNormal()
{
Cursor.SetCursor(cursorNormal, hotSpot, cursorMode);
currentCursorState = "cursorNormal"; // removing this line causes it to get stuck on cursorHover instead
if (debugCursorEvents) { print("CursorNormal() has been called"); }
}
void Update()
{
if (debugCursorEvents)
{
print("Current Cursor State is " + currentCursorState);
}
}
}