Getting a weird error I some how cant get my head around!!??
var paused : boolean = false;
var graphicsMenu : boolean = false;
var graphicsLevel : int;
var cam : Transform;
function Start()
{
defaultGuiColor = GUI.color;
graphicsLevel = QualitySettings.GetQualityLevel();
transform.GetComponent(MouseLook).enabled = true;
}
function resetGame()
{
paused = false;
Time.timeScale = 1.0;
Application.LoadLevel(Application.loadedLevel);
}
function OnGUI()
{
if (paused == true)
{
//make background slightly darker
GUI.Box(Rect(0,0,Screen.width,Screen.height), "");
}
//make buttons for pause menu
if (GUI.Button (new Rect ((Screen.width/2)-50, (Screen.height/2)-100, 100, 30), "Resume"))
{
cam.BroadcastMessage("pauseToggle");
paused = !paused;
graphicsMenu = false;
transform.GetComponent(MouseLook).enabled = true;
Time.timeScale = 1;
return;
}
if (GUI.Button (new Rect ((Screen.width/2)-50, (Screen.height/2)-50, 100, 30), "Restart"))
{
resetGame();
}
if (GUI.Button (new Rect ((Screen.width/2)-50, (Screen.height/2), 100, 30), "Video"))
{
graphicsMenu = !graphicsMenu;
}
if (GUI.Button (new Rect ((Screen.width/2)-50, (Screen.height/2)+50, 100, 30), "Quit"))
{
// Application.LoadLevel(0);
}
}
if (graphicsMenu == true)
{
if (graphicsLevel == 0){GUI.Label (Rect ((Screen.width/2)+100, (Screen.height/2)-35, 200, 30), "Graphics Setting: Very Low");}
if (graphicsLevel == 1){GUI.Label (Rect ((Screen.width/2)+100, (Screen.height/2)-35, 200, 30), "Graphics Setting: Low");}
if (graphicsLevel == 2){GUI.Label (Rect ((Screen.width/2)+100, (Screen.height/2)-35, 200, 30), "Graphics Setting: Medium");}
if (graphicsLevel == 3){GUI.Label (Rect ((Screen.width/2)+100, (Screen.height/2)-35, 200, 30), "Graphics Setting: High");}
if (graphicsLevel == 4){GUI.Label (Rect ((Screen.width/2)+100, (Screen.height/2)-35, 200, 30), "Graphics Setting: Ultra");}
graphicsLevel = GUI.HorizontalSlider (Rect ((Screen.width/2)+100, (Screen.height/2)+5, 100, 30), graphicsLevel, 0, 4);
QualitySettings.SetQualityLevel(graphicsLevel);
}
function Update ()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
//tell camera to pause
cam.BroadcastMessage("pauseToggle");
graphicsMenu = false;
{
//disable movement and toggle pause
transform.GetComponent(MouseLook).enabled = false;
paused = true;
return;
}
//allow movement and toggle pause
transform.GetComponent(MouseLook).enabled = true;
Time.timeScale = 1;
paused = false;
return;
}
}