I’ve got this code, but when i press the pause button it will not execute it, if i check the Paused bool in the inspector it will execute it immediately, but how do i fix it to make it work?
#pragma strict
var paused = false;
var isButtonVisible : boolean = true;
function OnMouseDown(){
this.paused = !this.paused;
Time.timeScale = 0;
isButtonVisible = true;
}
function OnGUI(){
if ( isButtonVisible ) {
if(this.paused){
if (GUI.Button(Rect(Screen.width/2-100,Screen.height/2+3,200,50),"Restart")){
Application.LoadLevel(Application.loadedLevel);
Time.timeScale = 1;
isButtonVisible = false;
}
if (GUI.Button(Rect(Screen.width/2-100,Screen.height/2-50,200,50),"Resume")){
Time.timeScale = 1;
isButtonVisible = false;
}
// Insert the rest of the pause menu logic
if (GUI.Button(Rect(Screen.width/2-100,Screen.height/2+56,200,50),"Main Menu")){
Application.LoadLevel ("MainMenu");
isButtonVisible = false;
Time.timeScale = 1;
}
}
}
}