x


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;
        }
    }
}
more ▼

asked Jul 25 '11 at 04:17 PM

Tim.Holman gravatar image

Tim.Holman
136 25 25 27

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.

Jul 25 '11 at 04:39 PM Alec Slayden
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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!

more ▼

answered Jul 25 '11 at 05:18 PM

Tim.Holman gravatar image

Tim.Holman
136 25 25 27

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x261
x198
x78
x18

asked: Jul 25 '11 at 04:17 PM

Seen: 955 times

Last Updated: Jul 25 '11 at 06:27 PM