Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Resolved How to create indent?...

Discussion in 'Immediate Mode GUI (IMGUI)' started by AzpxMsw, Oct 30, 2022.

  1. AzpxMsw

    AzpxMsw

    Joined:
    Jun 1, 2020
    Posts:
    12
    I need to create a small indent next to Sample1/2/3 after Foldout action. Here is a code:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5.  
    6. public class SampleWindow : EditorWindow
    7. {
    8.     bool Colliders;
    9.     bool Other;
    10.     bool Sample1;
    11.     bool Sample2;
    12.     bool Sample3;
    13.  
    14.     Vector2 scrollView = Vector2.zero;
    15.  
    16.     [MenuItem("Window/Other/Open Sample Window #M")]
    17.     static void onOpen()
    18.     {
    19.         EditorWindow.GetWindow(typeof(SampleWindow));
    20.     }
    21.  
    22.     void OnGUI()
    23.     {
    24.         Colliders = EditorGUILayout.Foldout(Colliders, "Colliders");
    25.         if (Colliders)
    26.         {
    27.             EditorGUILayout.BeginHorizontal();
    28.             if (GUILayout.Button("Box", GUILayout.MinWidth(115), GUILayout.MaxWidth(135)))
    29.             {
    30.                 GameObject build = new GameObject("Box");
    31.                 BoxCollider collider = build.AddComponent<BoxCollider>();
    32.                 collider.isTrigger = true;
    33.                 Selection.activeGameObject = build;
    34.             }
    35.             if (GUILayout.Button("Mesh", GUILayout.MinWidth(115), GUILayout.MaxWidth(135)))
    36.             {
    37.                 GameObject build = new GameObject("Mesh");
    38.                 build.AddComponent<UnityEngine.MeshCollider>();
    39.                 Selection.activeGameObject = build;
    40.             }
    41.             EditorGUILayout.EndHorizontal();
    42.         }
    43.  
    44.         Other = EditorGUILayout.Foldout(Other, "Other");
    45.         if (Other)
    46.         {
    47.             //Here I need to create indents near to Sample1/2/3 foldouts
    48.  
    49.             Sample1 = EditorGUILayout.Foldout(Sample1, "Sample1");
    50.             if (Sample1)
    51.             {
    52.             }
    53.  
    54.             Sample2 = EditorGUILayout.Foldout(Sample2, "Sample2");
    55.             if (Sample2)
    56.             {
    57.             }
    58.  
    59.             Sample3 = EditorGUILayout.Foldout(Sample3, "Sample1");
    60.             if (Sample3)
    61.             {
    62.             }
    63.         }
    64.     }
    65. }
    66.  
     
  2. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,136
  3. AzpxMsw

    AzpxMsw

    Joined:
    Jun 1, 2020
    Posts:
    12
    Thank you a lot!
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    9,059
    Do not use the General Discussion for support please as its description states.

    I'll move your UI post to the UI forum.