I’m working on a main menu. I’m trying to get a bunch of toggle options in the settings, but no matter which one you toggle, it only toggles on and off the first one.
Here is the script:
enter code herestatic var Quality : boolean = false;
private var displayLabel : boolean;
private var toggleTxt : boolean = false;
private var toggleTxt1 : boolean = false;
function Start(){
displayLabel = false;
}
function OnGUI () {
GUI.skin = customSkin;
GUI.Box(new Rect(20,20,200,100),"");
//You can change name for your box (before parentheses & after last comma)//Also you can resize the box by changing the numbers(first two numbers for the position & the last two numbers for size the GUI objects)
if(GUI.Button(Rect(25,25,70,20),"Join")){
Debug.Log("You clicked that button");
}
if(GUI.Button(Rect(25,50,70,20),"Settings")){
displayLabel = true;
}
if(displayLabel){
GUI.Box(Rect (500,20,200,100),"Settings");
}
if(displayLabel){
toggleTxt = GUI.Toggle(Rect(500, 50, 200, 100), toggleTxt, "Fastest");
if(toggleTxt){
RenderSettings.ambientLight = Color.red;
Quality = true;
}
else
{
toggleTxt = false;
RenderSettings.ambientLight = Color.clear;
}
}
if(displayLabel){
toggleTxt1 = GUI.Toggle(Rect(500, 65, 200, 100), toggleTxt1, "Fast");
if(toggleTxt1){
RenderSettings.ambientLight = Color.red;
Quality1 = true;
}
else
{
toggleTxt1 = false;
RenderSettings.ambientLight = Color.clear;
}
}
//That's how to create a GUI button//(The same)
GUI.Label(new Rect(Screen.width - 500,0,100,50), "Task Force-8");
//You can change name for this label by typing words (before parentheses & after last comma)
}