Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Undocumented EditorGUI.Popup Feature

Discussion in 'Documentation' started by Sarah-Mainwaring, Nov 5, 2015.

  1. Sarah-Mainwaring

    Sarah-Mainwaring

    Joined:
    Feb 24, 2014
    Posts:
    9
    Hi Unity,

    I was playing around in PropertyDrawers today and found an undocumented feature of EditorGUI.Popup. When you format your displayedOptions array elements with "/" characters in the strings the popup will create sub-menus collecting options that shared the same roots.

    So for instance the code below will generate the popup menus in the linked image.

    Code (CSharp):
    1. int selectedIndex = EditorGUI.Popup(
    2.       position,
    3.       label.text,
    4.       0,
    5.       new string[4] { "Split1/Value1", "Split1/Value2", "Split2/Value1", "Split2/Value2" });


    I know that this is known to a few others but I just happened to stumble across this feature as I was unaware it was even possible. I would have loved to have known about it on an earlier project this year. I'd like to put in a request to have this feature added to the documentation of EditorGUI.Popup so that others can benefit from it.

    Sarah
     
  2. duck

    duck

    Unity Technologies

    Joined:
    Oct 21, 2008
    Posts:
    358
    Hi Sarah,

    Thanks for pointing that out. I've made a note to have this added to the docs. By the way this also works for the layers and tags menu items!

    penfold.gif
     
    S_Darkwell likes this.
  3. Sarah-Mainwaring

    Sarah-Mainwaring

    Joined:
    Feb 24, 2014
    Posts:
    9
    Thanks for getting back so quickly and for that excellent animation.