This is the error message I am receiving when I pause the game? BCE0044: expecting :, found ';'. This is the code. Code (csharp): var paused : boolean = false; var windowWidth : int = 150; var windowHeight : int = 200; var windowRect : Rect = Rect( Screen.width/2 - windowWidth/2, Screen.height/2 - windowHeight/2, windowWidth, windowHeight ); function Update () { if(Input.GetButtonUp("Fire3")){ if(!paused){ Time.timeScale = 0; paused = true; } else { paused = false; Time.timeScale = 1; } } } function OnGUI() { if( paused ) { // 3rd parameter is the function where you will place all your GUI controls that should be in the window GUI.Window( 0, windowRect, PausedWindow, "Paused" ); } } function PausedWindow() { //all your buttons or other gui components for your window go here, for example: GUI.Button( Rect( 5, 10, 70, 20 ), "Main Menu" ); { Application.LoadLevel(1); } }
if(Input.GetButtonUp("Fire3")) { if(!paused) { Time.timeScale = 0; paused = true; } } <---------------------------------------------------This is Missing else
I still did it and got the same error message. Code (csharp): var paused : boolean = false; var windowWidth : int = 150; var windowHeight : int = 200; var windowRect : Rect = Rect( Screen.width/2 - windowWidth/2, Screen.height/2 - windowHeight/2, windowWidth, windowHeight ); function Update () { if(Input.GetButtonUp("Fire3")){ if(!paused){ Time.timeScale = 0; paused = true; } } else { paused = false; Time.timeScale = 1; } } function OnGUI() { if( paused ) { // 3rd parameter is the function where you will place all your GUI controls that should be in the window GUI.Window( 0, windowRect, PausedWindow, "Paused" ); } } function PausedWindow() { //all your buttons or other gui components for your window go here, for example: GUI.Button( Rect( 5, 10, 70, 20 ), "Main Menu" ); { Application.LoadLevel(1); } }
Code (csharp): GUI.Button( Rect( 5, 10, 70, 20 ), "Main Menu" ); { Application.LoadLevel(1); } should be Code (csharp): if (GUI.Button( Rect( 5, 10, 70, 20 ), "Main Menu" )) { Application.LoadLevel(1); }
The menu is working. However,when I press the Letter P for the pause button, it will not stay on the screen. It pops up and then leaves. Code (csharp): function Update () { if(Input.GetButtonUp("Fire3")){ if(!paused){ Time.timeScale = 0; paused = true; } } THis is the top part of my code.