I have a simple, in-game pause menu that just says, Paused, and has a quit button. It works fine except when I go to actually open the menu with the esc button, it just flashes open the closes really quick. I have to press and hold it for it to open without closing on its own. This is my code, can anyone help me get to open with just one button press?
function Update () {
if(Input.GetKey(KeyCode.Escape)){
if(Time.timeScale == 0){
Time.timeScale = 1;
}
else {
Time.timeScale = 0;
}
}
}
function OnGUI(){
if(Time.timeScale == 0){
ButtonGUI();
}
}
function ButtonGUI() {
//------------------------------------------------------------------------------------------------------//
GUI.Label (Rect (100, 25, 200, 60), “PAUSED”);
if (GUI.Button (Rect (100, 55, 100, 30), "Quit")) {
Application.Quit();
}
//-------------------------------------------------------------------------------------------------------//
}