- Home /
EditorGUILayout.Foldout seems to stop working past indent 3
I am creating an editor tool that requires a hierarchical tree. It should look something like this:
A lot of my code is based on EditorGUI.indentLevel
for correct positioning, but I noticed some GUI elements don't work past an intend of 3.
This seems like a bug to me, but hopefully someone knows a workaround.
public class TestEditor : EditorWindow
{
[MenuItem("Window/Test Editor")]
internal static void Init()
{
GetWindow(typeof(TestEditor), false, "Sorted Inspector");
}
private bool foldout;
private void OnGUI()
{
EditorGUI.indentLevel+= 4;
EditorGUILayout.BeginHorizontal();
foldout = EditorGUILayout.Foldout(foldout, "Foldout");
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
if (foldout)
EditorGUILayout.LabelField("Expanded");
EditorGUI.indentLevel-= 4;
}
}
If you run this code, you'll notice the foldout doesn't do anything when clicked.
Comment