- Home /
Combining if Statements
I have 3 if statements for when you press the submit button it is checking the values of the GUI Toggles. If the player chooses only one of them (3rd if statement) then I want the game to resume. If the player doesnt choose any of them (1st statement) I have a script that tells them to fix it and finally I have if the player chooses both (2nd Statement) I have a script that will make them fix it as well. The problem is I can get all of them individually to work but when I combine them together such as this, only the first if statement will work. How do i combine all three?
if(GUI.Button(Rect(325, 500, 150, 40), "Submit")){ if(toggle1M == false && toggle2F == false) {
}
}
else if(GUI.Button(Rect(325, 500, 150, 40), "Submit")){
if(toggle1M == true && toggle2F == true){
}
}
else if(GUI.Button(Rect(325, 500, 150, 40), "Submit")){
}
Answer by rejj · May 01, 2011 at 08:38 AM
You'll need to move all the secondary if
statements to be inside a single check for clicking the GUI.Button()
.
if(GUI.Button(Rect(325, 500, 150, 40), "Submit")){ if(!toggle1M && !toggle2F) { // ... }
else if(toggle1M && !toggle2F){
// ...
}
else {
// ...
}
}