- Home /
Make use of a button in a drop down menu?
Hello people,
my problem is: I made a simple drop down menu by a script. Now, when I want to add some function to 1 of the 4 buttons (e.g. just if button 1 is clicked then print : "button 1 is clicked"). I tried to add an if function to the script but the result is that when the button "Button Label" is pressed I can see in the console that my function is already executed. This is not what I'm looking for! I want that if you press button 1 my text is printed!!! How can I change this? The only thing I want to do is to add some functions to my buttons.
Thanx to everyone who is answering!!! ;-)
pragma strict
function Start () {
}
function Update () {
}
private var showMenu : boolean = false;
function OnGUI(){
if(GUI.Button(Rect(20,10,100,30),"Button Label")){
if(showMenu == false)
showMenu = true;
else
showMenu = false;
}
if(showMenu == true){
GUI.Box(Rect(10, 50, 120, 170), "");
if (GUI.Button(Rect(20, 60, 100, 30 ), "Button 1")); // here somewhere is my problem!!!
{
print ("You clicked the button!");
}
GUI.Button(Rect(20, 100, 100, 30 ), "Button 2");
GUI.Button(Rect(20, 140, 100, 30 ), "Button 3");
GUI.Button(Rect(20, 180, 100, 30 ), "Button 4");
}
}
Comment