Hi,
So this is probably a really dumb question since it’s my first project in Unity, but here goes anyways.
To clarify things, the plane is a “card” that when the user hover over it with the mouse, a selection gizmo should appear (visual feedback). Now, when the mouse is over the plane, it sends “true” via the gizmo’s Switch function. So far, this works. The problem is that at Update(), the value is set back to false every time.
There is nothing else in my project besides the plane (card) and the gizmo.
I have this plane with this script:
public GameObject gizmo;
void OnMouseOver()
{
gizmo.GetComponent<GizmoBehavior>().Switch(true);
}
void OnMouseExit()
{
gizmo.GetComponent<GizmoBehavior>().Switch(false);
}
and then this simple Script attached to my “gizmo”:
private bool bIsVisible;
// Update is called once per frame
void Update () {
Debug.Log(bIsVisible);
}
public void Switch(bool state)
{
// true = on (visible)
// false = off (not visible)
bIsVisible = state;
Debug.Log("Switch : " + bIsVisible);
}
Now, this is the console output:
False
UnityEngine.Debug:Log(Object)
Switch : true
UnityEngine.Debug:Log(Object)
… Meaning the value is correctly passed to my gizmo but somehow at Update() the value is reset back to false. I don’t understand why.