I’m working on a Main Menue and i don’t know if this is code-technically a mess or halfway okay. My code so far:
#pragma strict
var customGuiStyle : GUIStyle;
var textureToDisplay : Texture2D;
private var OptionsMenuEnabled = false;
private var toggleBloom : boolean = false;
private var toggleDoF : boolean = false;
function Start(){
OptionsMenuEnabled = false;
}
function OnGUI () {
GUI.Label (Rect (45, 25, textureToDisplay.width, textureToDisplay.height), textureToDisplay);
if (GUI.Button (Rect (125, 195, 130, 40), "Start", customGuiStyle)) {
Application.LoadLevel (2);
}
if (GUI.Button (Rect (125, 245, 130, 40), "Options", customGuiStyle)) {
//OptionsMenuEnabled = true;
if(OptionsMenuEnabled == false){
OptionsMenuEnabled = true;
}
else{
OptionsMenuEnabled = false;
}
}
if (GUI.Button (Rect (125, 295, 130, 40), "Credits", customGuiStyle)) {
Application.LoadLevel (1);
}
if (GUI.Button (Rect (125, 345, 130, 40), "Exit", customGuiStyle)) {
Application.Quit();
}
//------------ MENUES
if(OptionsMenuEnabled == true){
GUI.Label (Rect (430, 195, 290, 40), "Options...", customGuiStyle);
GUI.Label (Rect (430, 235, 990, 40), "______________________________________________");
GUI.Label (Rect (430, 275, 290, 40), "Bloom");
//SETTING FOR BLOOM
if (GUI.Toggle(Rect(630, 275, 290, 40), toggleBloom, "On/Off")) {
toggleBloom = true;
//ENABLE Bloom IE
}
else{
toggleBloom = false;
//DISABLE Bloom IE
}
GUI.Label (Rect (430, 315, 290, 40), "Depth of Field");
//SETTING FOR DoF
if (GUI.Toggle(Rect(630, 275, 290, 40), toggleBloom, "On/Off")) {
toggleDoF = true;
//ENABLE DoF IE
}
else{
toggleDoF = false;
//DISABLE DoF IE
}
}
//GUI.Label (Rect (45, 395, 130, 40), "ver 1.0.0");
GUI.Label (Rect (45, 425, 290, 40), "Song: Danosongs - The Streatham Hills Gods");
}
Another thing: This app will have serveral levels, which I all load via Application.LoadLevel. The user can change the quality settings in the Main/Options menue (only!, for now), but do I need PlayerPrefs in order to port these changed settings into other levels?
-Mauri