Search Unity

Creating a switchable EditorWindow Like the Lighting Tab

Discussion in 'Immediate Mode GUI (IMGUI)' started by Maaalene, Apr 4, 2019.

  1. Maaalene

    Maaalene

    Joined:
    Jan 5, 2018
    Posts:
    2
    Hello,

    I am trying to create an EditorWindow that works on objects in assets and on objects in the scene but differentiate between those two usages. The options should be a bit different, so I want to create a toggle that enables switching between two different GUI setups.
    Does anybody know how I can create toggle buttons similar to the Lighting Tab (see top of appended image)?

    Thanks for any help!

    upload_2019-4-4_11-44-25.png
     
  2. PsyKaw

    PsyKaw

    Joined:
    Aug 16, 2012
    Posts:
    102
    You can do it like this:
    Code (CSharp):
    1.  
    2. private int m_tab;
    3. private void OnGUI()
    4. {
    5.     m_tab = GUILayout.Toolbar(m_tab, new string[] { "Scene", "Global Maps", "Object Maps" }, "LargeButton");
    6.     switch(m_tab)
    7.     {
    8.         case 0:
    9.             //Scene
    10.             break;
    11.         case 1:
    12.             //Global Maps
    13.             break;
    14.         case 2:
    15.             //Object Maps
    16.             break;
    17.     }
    18. }
    19.  
     
    Maaalene likes this.
  3. Maaalene

    Maaalene

    Joined:
    Jan 5, 2018
    Posts:
    2
    Thanks a lot!