Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Editor inspector formatting?

Discussion in 'Immediate Mode GUI (IMGUI)' started by bibbinator, Jan 27, 2010.

  1. bibbinator

    bibbinator

    Joined:
    Nov 20, 2009
    Posts:
    507
    Hi,
    I noticed that some inspectors have nice indenting on child objects or font formatting such as bold for headings to help make the inspector more organized.

    How are foldout children indented? Is this all custom style options? Or is there an easy way out of the box to do this? Using the layout groups doesn't seem to automatically help with indenting.

    Thanks.
     
  2. Molix

    Molix

    Joined:
    Apr 24, 2009
    Posts:
    92
    To indent under a foldout, I typically create a new "horizontal", space it, and then continue with a new "vertical". Something like:

    Code (csharp):
    1. GUILayout.BeginVertical();
    2. foldout = EditorGUILayout.Foldout( .. )
    3. if( foldout )
    4. {
    5.   GUILayout.BeginHorizontal();
    6.     GUILayout.Space( indentPixels );
    7.     GUILayout.BeginVertical();
    8.       GUILayout.Label("I'm indented in the foldout");
    9.       GUILayout.Label("Me too");
    10.     GUILayout.EndVertical();
    11.   GUILayout.EndHorizontal();
    12. }
    13. GUILayout.EndVertical();
     
  3. bibbinator

    bibbinator

    Joined:
    Nov 20, 2009
    Posts:
    507
    Thanks for the help! I somehow missed the GUILayout.Space call...
     
  4. Toxic Blob

    Toxic Blob

    Joined:
    Jun 8, 2010
    Posts:
    18
    It doesn’t seem to be documented that GUILayout.Space() can take an integer as a parameter. Very useful to know! Thanks