Home > other >  Why my GUILayout is outside my FoldoutHeaderGroup ? Unity editor
Why my GUILayout is outside my FoldoutHeaderGroup ? Unity editor

Time:11-17

I'm a Unity tools developer and i want to put a GUILayout.Label(" title ") inside a FoldoutHeaderGroup so i did that :

    using UnityEditor;
    using UnityEngine;

    public class tesdtEditor : EditorWindow
    {
        private bool showWindowFoldOut;

        [MenuItem("test")]
        public static void ShowWindow()
        {
            EditorWindow.GetWindow(typeof(tesdtEditor));
        }

        public void OnGUI()
        {
            showWindowFoldOut = EditorGUILayout.BeginFoldoutHeaderGroup(showWindowFoldOut, "foldout Name");

            GUILayout.Label("title");

            EditorGUILayout.EndFoldoutHeaderGroup();
        }
    }

But it's not in my FoldoutHeaderGroup (Screen of the window)

I can't see where I'm mistaken, can someone guide me through ?

CodePudding user response:

You still need to check the

if(showWindowFoldOut)
{
    EditorGUI.indentLevel  ;

    GUILayout.Label("title");

    EditorGUI.indentLevel--;
}

See example in EditorGUILayout.BeginFoldoutHeaderGroup.


Tbh besides the different styling I didn't understand so far what the difference is between that and a simple EditorGUILayout.Foldout.

  • Related