- Home /
How to hide cursor after pause menu resume
I've got a script that hides my mouse cursor until the pause menu is brought up. My problem is that once the player brings up the pause menu, then hits the "Resume" button, the cursor does not go away again. I assume there would be some command to say "if gui button "resume", Screen.showCursor = false;" However, I am not an experienced progammer. Any suggestions would be greatly appreciated. Here's the code I currently have:
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;
}
}
}
Try a built version of that level. I've noticed that the editor doesn't like taking the mouse back after you first release it.
Answer by Tim.Holman · Jul 25, 2011 at 05:18 PM
I figured it out. Just needed to add the following line to my PauseMenuScript under the resume button command.
Screen.showCursor = false
Also had to modify a few other scripts to prevent the audio from playing during pause.
Simple as that!
Your answer
Follow this Question
Related Questions
Script that makes the mouse cursor invisible. 3 Answers
Cursor help 1 Answer
2D main menu as a different scene - pausing and resuming 0 Answers
Pause menu script, mouse not hiding 1 Answer