I have a GameManager script holding the bool variable bDisplayMenu. I want to toggle this boolean to control the menu display in the PlayerMovement script. It toggles on, drawing the menu when I press the assigned button, but never disappears. I would appreciate the help figuring this one out.
This is the relevant bit of GameManager:
public class GameManager : MonoBehaviour
{
public static bool bDisplayMenu;
void OnGUI()
{
if(bDisplayMenu == true)
{
Texture2D tSkin = Resources.Load("Polkdot") as Texture2D;
GUI.Box(new Rect(20, 20, 100, 380), "Blah");
// DRAWING SLOTS - NOT INTERACTABLE ========
GUI.Box(new Rect(40, 40, 60, 60), tSkin);
GUI.Box(new Rect(40, 120, 60, 60), tSkin);
GUI.Box(new Rect(40, 200, 60, 60), tSkin);
GUI.Box(new Rect(40, 280, 60, 60), tSkin);
}
else
{
Debug.Log ("Else");
}
}
}
And PlayerMovement:
public class PlayerMovement : MonoBehaviour
{
void Update()
{
if(Input.GetButtonDown("Menu"))
{
Debug.Log (GameManager.bDisplayMenu);
GameManager.bDisplayMenu = !bDisplayMenu;
Debug.Log (GameManager.bDisplayMenu);
}
}
If it helps to note: I tried copy-pasting the OnGui text from GameManager to PlayerMovement (adjusting the variable reference) and when I do that it simply never fires.
Any help is appreciated, thanks!