I’m trying to script a pause menu for my game but it say unexpected token: ; and all the compiler errors have to be fixed here is the script
public class PauseMenu ; MonoBehaviour ;
var menuHeight:float=500;
var menuWidth:float=500;
var buttonSpacing:float=25;
var pauseMenu: String = (“PauseMenu”);
var titleTexture:Texture2D;
var customSkin:GUISkin;
var customStyle:GUIStyle;
function OnGUI(){
GUI.skin = customSkin;
GUILayout.BeginArea(Rect(Screen.width/2-menuWidth/2,Screen.height/2-menuHeight/2,menuHeight,menuWidth),customStyle);
GUILayout.Space(50);
GUILayout.Label(titleTexture);
GUILayout.Space(buttonSpacing);
if(GUILayout.Button(“Resume”)){
Application.LoadLevel(mainMenu);
}
GUILayout.Space(buttonSpacing);
if(GUILayout.Button(“Exit to Desktop”)){
Application.Quit();
}
GUILayout.Space(buttonSpacing);
GUILayout.EndArea();
}
Firstly, please format your code using the buttons at the top of the post window, it should look something like this:
public class PauseMenu ; MonoBehaviour ;
var menuHeight:float=500;
var menuWidth:float=500;
var buttonSpacing:float=25;
var pauseMenu: String = ("PauseMenu");
var titleTexture:Texture2D;
var customSkin:GUISkin;
var customStyle:GUIStyle;
function OnGUI(){
GUI.skin = customSkin;
GUILayout.BeginArea(Rect(Screen.width/2-menuWidth/2,Screen.height/2-menuHeight/2,menuHeight,menuWidth),customStyle);
GUILayout.Space(50); GUILayout.Label(titleTexture);
GUILayout.Space(buttonSpacing);
if(GUILayout.Button("Resume"))
{
Application.LoadLevel(mainMenu);
}
GUILayout.Space(buttonSpacing);
if(GUILayout.Button("Exit to Desktop"))
{
Application.Quit();
}
GUILayout.Space(buttonSpacing);
GUILayout.EndArea();
}
Now that it’s legible, the error your getting is from the first line, where the first ; should be a :, and the second should be a {, like this:
public class PauseMenu : MonoBehaviour {