- Home /
Opening a second gui
I have a script that opens a GUIBox that let's you attack or defend. I need to make it open a second GUI with choices for different attacks. Like pokemon or an RPG.
Can anyone suggest a method?
Answer by The_r0nin · Dec 13, 2010 at 07:06 PM
OnGUI(){
if (GUI.Button(Rect(Screen.width/2,Screen.height/2, 50, 50), "Attack"){
if (GUI.Button(Rect(Screen.width/2,Screen.height/2, 50, 50), "Punch"){
DoPunch();
}
if (GUI.Button(Rect(Screen.width/2,Screen.height/2, 50, 50), "Kick"){
DoKick();
}
}
}
This should work for any GUI element that lets you select a response. Just nest them. If you want the original box to stay visible, then you need to mess with dialogue variables (if they click "attack" on the box, set var boxResponse to 1 and then have an if statement in your OnGUI that says if (boxResponse == 1) followed by your new GUI code... but that's a little more messy...)
I tried it but no luck. The menu for the second doesn't appear.
Never $$anonymous$$d, It was a mistake on my behalf since it's a little more complicated than I let on.
Your answer
![](https://koobas.hobune.stream/wayback/20220613090911im_/https://answers.unity.com/themes/thub/images/avi.jpg)