Custom inspector: changing foldout's text color


I built a custom inspector, but I can't find a way to change the Foldout element text color.

I created a custom GUIStyle to use (`foldoutStyle = new GUIStyle(EditorStyles.foldout)`), and I'm trying to change its color via the usual `foldoutStyle.[render state].textColor` property. The thing is, nothing happens.

I tried all the possible render settings (foldoutStyle.normal, hover, active, onNormal, onHover, onActive, focused, onFocused), but to no avail. Or better, setting the `focused.textColor` property actually changes the text color, but only if the Foldout is closed. I can't find a way to change the Foldout color when it's open.

Any idea?

Thanks & a nice day :)


This works fine in any mode:

GUIStyle myFoldoutStyle = new GUIStyle(EditorStyles.foldout);
Color myStyleColor =;
myFoldoutStyle.fontStyle = FontStyle.Bold;
myFoldoutStyle.normal.textColor = myStyleColor;
myFoldoutStyle.onNormal.textColor = myStyleColor;
myFoldoutStyle.hover.textColor = myStyleColor;
myFoldoutStyle.onHover.textColor = myStyleColor;
myFoldoutStyle.focused.textColor = myStyleColor;
myFoldoutStyle.onFocused.textColor = myStyleColor; = myStyleColor;
myFoldoutStyle.onActive.textColor = myStyleColor;

Had the similar problem some weeks ago. I used `EditorGUIUtility.LookLikeInspector()`

and it works as expected. Even the function changes: Now you can click on the text to toggle. The control-style foldout ( EditorGUIUtility.LookLikeControls() ) only toggles when you click on the small arrow.

Don't know if there is a way to change the color of the control-style foldout... haven't found one yet.

Not really an answer, but some data based on Bunny83's hack (while waiting for an eventual non-hack solution - if it exists :P).

The unstylable Foldout issue happens if you're using the `EditorGUIUtility.LookLikeControls()` mode

Otherwise, it's still a mess! Applying `EditorGUIUtility.LookLikeInspector()` just before the Foldout creation (and reverting to `LookLikeControls()` immediately after) allows to style the Foldout, though not that easily. Here is a list of render settings for each Foldout state (the unlisted ones have no use):

  • normal: Foldout closed and unfocused
  • active: on Foldout click when closed
  • onNormal: Foldout open and unfocused
  • onActive: on Foldout click when open
  • onFocused: Foldout open and focused (attention here: needs onActive and focused to be set/changed, otherwise it doesn't work!)
  • focused: Foldout closed and focused

I tested this not by creating an entirely new GUIStyle, but by cloning the default with `foldoutStyle = new GUIStyle(EditorStyles.foldout)`