EditorGUILayout.Foldout() bug?

I noticed if you put a an EditorStyle to a Editor Foldout it changes from being a ‘foldout’ and instead is a more like a title bar with a soft blue shading to it… and no longer functions to expand/collapse the elements inside the foldout

To repro - change one of your foldouts

EditorGUILayout.Foldout(foo, "Foo");

to…

EditorGUILayout.Foldout(foo, "Foo", EditorStyles.boldLabel);

Is this expected behaviour?

I just ran into this. Surprised that it has not been addressed yet. I submitted a bug report.

Well, you kinda kill the foldout style, and you expect it to keep working?

I just want it to be bold. Got any suggestions?

Something like;

            GUIStyle style = EditorStyles.foldout;
            FontStyle previousStyle = style.fontStyle;
            style.fontStyle = FontStyle.Bold;
            EditorGUI.Foldout(rect, foldout, content, style);
            style.fontStyle = previousStyle;
1 Like

Wow, that works. And it was kind of obvious too. :slight_smile:

I’ve seen that pattern before of copying an existing style, making a change, then applying it.

But I could not figure out which style to use as a base.

Thanks!