hello, im trying to make a load game button in my game, but there is allways errors.
i can save my game and load my game when im playing but i want to load the game from the main menu to.
please help me.
This is my script:
var mainMenuSceneName : String;
var pauseMenuFont : Font;
private var showGraphicsDropDown = false;
function OnGUI(){
//Make a background box
GUI.Box(Rect(Screen.width /2 - 100,Screen.height /2 - 100,250,200), "Darkness");
//Make Main Menu button
if(GUI.Button(Rect(Screen.width /2 - 100,Screen.height /2 - 50,250,50), "Start"))
Application.LoadLevel(1);
//Make Change Graphics Quality button
if(GUI.Button(Rect(Screen.width /2 - 100,Screen.height /2 ,250,50), "Options"))
/* EDIT : You can toggle a boolean by affecting its opposite, with ! */
/*{
if(showGraphicsDropDown == false)
showGraphicsDropDown = true;
else
showGraphicsDropDown = false;
}*/
showGraphicsDropDown = !showGraphicsDropDown;
//Create the Graphics settings buttons, these won't show automatically, they will be called when
//the user clicks on the "Change Graphics Quality" Button, and then dissapear when they click
//on it again....
if( showGraphicsDropDown ) /* EDIT boolean == true is redundant */
{
if(GUI.Button(Rect(Screen.width /2 + 150,Screen.height /2 ,250,50), "Fastest"))
QualitySettings.currentLevel = QualityLevel.Fastest;
if(GUI.Button(Rect(Screen.width /2 + 150,Screen.height /2 + 50,250,50), "Fast"))
QualitySettings.currentLevel = QualityLevel.Fast;
if(GUI.Button(Rect(Screen.width /2 + 150,Screen.height /2 + 100,250,50), "Simple"))
QualitySettings.currentLevel = QualityLevel.Simple;
if(GUI.Button(Rect(Screen.width /2 + 150,Screen.height /2 + 150,250,50), "Good"))
QualitySettings.currentLevel = QualityLevel.Good;
if(GUI.Button(Rect(Screen.width /2 + 150,Screen.height /2 + 200,250,50), "Beautiful"))
QualitySettings.currentLevel = QualityLevel.Beautiful;
if(GUI.Button(Rect(Screen.width /2 + 150,Screen.height /2 + 250,250,50), "Fantastic"))
QualitySettings.currentLevel = QualityLevel.Fantastic;
/* EDIT : Input should not be used in OnGUI */
//if(Input.GetKeyDown("escape"))
if( Event.current == EventType.KeyDown )
if( Event.current.keyCode == KeyCode.Escape )
showGraphicsDropDown = false;
}
//Make quit game button
if (GUI.Button (Rect (Screen.width /2 - 100,Screen.height /2 + 50,250,50), "Quit Game"))
Application.Quit();
}
[Edit by Berenger] I deleted empty lines to shorten the code and changed some stuff. Check them out, the have the mention /* EDIT … */ before them, with the reason.