private var showingCursor = false;
function Start(){
Screen.showCursor = false;
}
function Update(){
//check if pause button (escape key) is pressed
if(Input.GetKeyDown("escape")){
//check if game is already paused
if(showingCursor == true){
Screen.showCursor = false;
showingCursor = false;
Time.timeScale = 1;
AudioListener.volume = 1;
}
//else if game isn't paused, then pause it
else if(showingCursor == false){
Screen.showCursor = true;
showingCursor = true;
Time.timeScale = 0;
AudioListener.volume = 0;
}
}
}
This is part of a script that I have written for a pause menu.
What it does is when the player presses a key (i’ve made it escape but you can change it), then it shows the mouse pointer. Then if they press the same button again, it goes away…