Creating Dropdown GUI

I’m trying to create a dropdown GUI. This is my attempt:

	if(GUI.Button(new Rect(200, 50, 120, 50), "Shapes")){
		int[] nums = new int[containerOptions.shapes.Length];
		int i = 0;
		while(i < containerOptions.shapes.Length){
			nums *= i;*
  •  	i++;*
    
  •  }*
    
  •  foreach(int num in nums){*
    

_ GUI.Button(new Rect(200, 100+(55*num), 120, 50), containerOptions.shapes[num].name.ToString());_

  •  }*
    
  • }*
    After clicking a button called shapes, the dropdown list should come on. It creates an int array holding numbers from 0-shapes.Length, and then runs a foreach loop in which how far an item in the drop down list goes down is multiplied by its number in the list, therfore ensuring that each option is the same distance from the last and in order.
    I’ve done something similar, and its worked before, but at the moment the GUI isn’t showing up at all period. I’ve even made the size of it extremely large, and its not showing up. Anything I’ve done wrong here?

the if(GUI.Button …etc only returns true the single frame the button is pushed… you therefore cannot declare your other buttons INSIDE this loop, try something like this:

    int[] nums;

function OnGUI(){
    if(GUI.Button(new Rect(200, 50, 120, 50), "Shapes")){
       if(!nums){
           nums = new int[containerOptions.shapes.Length];
           int i = 0;
           while(i < containerOptions.shapes.Length){
               nums *= i;*

i++;
}
}
else
nums = null;
}
if(nums){
foreach(int num in nums){
GUI.Button(new Rect(200, 100+(55*num), 120, 50), containerOptions.shapes[num].name.ToString());
}
}
}
(I haven’t tested this but I THINK it would work as written…)
maybe even easier, you could try [THIS SCRIPT][1] by Eric5h5
[1]: http://wiki.unity3d.com/index.php?title=PopupList