I had something VERY weird happen today. I had a couple of return statements at the beginning of routines to show and hide a tooltip so that I could disable them. Our artist wanted to be able to have them on so I did something VERY simple and I cannot get it to work.
I added a variable…
public bool disableItemTooltips;
To the script then changed the tooltip routines…
public void ShowTooltip(GameObject slot)
{
if (disableItemTooltips)
{
return;
}
// Code to show the tooltip
}
No matter what I do in the inspector this does not work (the variable is ALWAYS true, even if I initialize it with = false)
Changing it in the inspector does nothing to the value
The only way I have been able to make it false is by initializing it as false and readonly
I had this issue on two different PCs so I am totally stumped
The problem definitely isn’t with this code. I feel like if it still changes with the readonly statement then it should throw an error. Nonetheless, select the variable and press shift command Y to see all the other areas its being referenced.
I have used “Find all references” in VS and it is definitely not referenced anywhere else and is referenced everywhere it should be. It used to be called disableTooltip but I renamed it in case it was hiding another variable that VS was not showing. I am going to try moving the variable into my game manager class because the script is attached to a GUI element on a canvas and I have seen some other wonkiness with GUI related scripts.
OK so I moved the variable to the GameManager script and everything works as expected. There seems to be some ugly bugs regarding scripts attached to GameObjects parented to a GUI Canvas.