I'm trying to implement a feature that would allow me to press a key and bring up a GUI. For example, I press Esc, and it brings up a GUI button that allows me to quit the game.
The problem I'm having is that When I press the button, they GUI stays up until the button is released. I want it to stay up until I press the button again. Obviously I'm missing a piece of code, here's what I have so far (JS)
you should have a variable called quitMenu
weh nyou press esc set it to true and then when you want to hide the menu set it to false.
if (GUI.GetButtonDown ("ESC")) { quitMenu=true;}
if (quitMenu == true)
{
if (GUI.Button (Rect(10,10,300,300),"quit")
{
//place your code here and also put
quitMenu = false;
}
}
define the quitMenu on top of your script as a private var.