Search Unity

Drop down menu

Discussion in 'Immediate Mode GUI (IMGUI)' started by Sync1B, Feb 21, 2008.

  1. Sync1B

    Sync1B

    Joined:
    Sep 13, 2005
    Posts:
    561
    Whats the best way to make a drop down menu? I kinda think this should be a GUI attribute. Any help?

    Bill
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The popup menu for paths in the file requester in Fractscape is basically like a drop-down menu. I did it like this:

    Code (csharp):
    1.     // Path list popup -- done last so it's drawn on top of other stuff
    2.     if (showPopup) {
    3.         GUI.Box (Rect(popupRect.x, popupRect.y, popupRect.width, 27*pathList.Length), "", popupBoxStyle);
    4.         selectedPath = GUI.SelectionGrid (Rect(popupRect.x+4, popupRect.y+4, popupRect.width-8, 27*pathList.Length-8), selectedPath, pathList, 1, listStyle);
    5.     }
    Hopefully that makes some sense out of context. pathList is a string[], and the others should be obvious.

    --Eric