Here you go matey.
Just copy this revised code over and you ll be fine
(this obviously needs to be attached to a gameobejct in your scene.
#pragma strict
var mainMenuSceneName : String;
private var pauseEnabled = false;
function Start()
{
pauseEnabled = false;
Time.timeScale = 1;
AudioListener.volume = 1;
Screen.showCursor = false;
}
function Update()
{
//check if pause button (escape key) is pressed
if(Input.GetKeyDown("escape"))
{
//check if game is already paused
if(pauseEnabled == true)
{
//unpause the game
pauseEnabled = false;
Time.timeScale = 1;
AudioListener.volume = 1;
Screen.showCursor = false;
}
//else if game isn't paused, then pause it
else if(pauseEnabled == false)
{
pauseEnabled = true;
AudioListener.volume = 0;
Time.timeScale = 0;
Screen.showCursor = true;
}
}
}//end Update function
function OnGUI()
{
if(pauseEnabled == true)
{
if(GUI.Button(Rect(Screen.width /2 - 100,Screen.height /2+25 ,250,50), "Option"))
{
Debug.Log("GUI.Button : Options : pressed");
}
if(GUI.Button(Rect(Screen.width /2 - 100,Screen.height /2-25 ,250,50), "Resume"))
{
if(pauseEnabled == true)
{
//unpause the game
pauseEnabled = false;
Time.timeScale = 1;
Screen.showCursor = false;
AudioListener.volume = 1;
}
}
}
}//end OnGUI function
Your issue was curly braces.
as a humble tip: When you look at a debugger line in the Unity Console…
Assets/dunno.js(61,1): BCE0044: expecting }, found ‘’.
Consider it in three parts.
Like so…
It is saying in the first section
Assets/YourScript.js(61,1)
that the error comes from the script named (YourScript)…
In the second section
BCE0044: expecting },
it`s telling you what the compiler was expecting to find, in this case a “}” closing curly brace, to end your function body.
Thirdly, it is simply telling you WHAT it ACTUALLY found/discovered, in this case nothing!, Nada!, nowt. Represented by the ‘’ part at the end of the sentence.
SO if you can split it into those three each time, you wont go far wrong and any variations, now you know this, are only ever slight with respect to the error statements Unity throws.
Anyhoo, hope that helped ya bud…
If so mark it as an answer as it may help others in the same pickle.
Also, try here for a few pointers and tips for good
Unity development…
Unity Tuts
Unity Gems
take care bud and thanks for reading
Gruffy