Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why my GUILayout is outside my FoldoutHeaderGroup ? Unity editor

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 ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading