sub menus

this is meant to be another example of my menu system.

this is a simple implementation, if you click on button first, then second opens.
if you click on second then third opens…

but it does nothing.
what’s wrong??
thanks
G.

var L1 = 0;
var L2 = 100;
var L3 = 200;

function OnGUI() {

if (GUI.Button (Rect (25+L1,20+45,120,20), "first")) {


if(GUI.Button (Rect (25+L2,20+55,120,20), "second")) {
	
	GUI.Button (Rect (25+L3,20+65,120,20), "third");
	}

}
}

GUI.Button only returns true the one frame it’s clicked on. You’d probably want to store the result of a click in a variable so you can use that indefinitely.

private var button1clicked = false;

function OnGUI () {
   if (GUI.Button (Rect (25+L1,20+45,120,20), "first")) {
      button1clicked = true;
   }
   if (button1clicked) {
      if (GUI.Button (Rect (25+L2,20+55,120,20), "second")) {
         //etc.
      }
   }
}

–Eric

you saved me.
it is exactly what I was looking for!
thanks
G>

:sweat_smile: :lol: :smile: