Default toggle style

I’m writing a custom editor inspector, which uses a custom skin. Everything seems to work fine, but I’ve found something which doesn’t act quite as I’d expect.

I’ve redefined the toggle style in my skin, however when using the following code, I see the default checkbox.

toggle = EditorGUILayout.Toggle(toggle);

When I change it to the following, I see my custom toggle:

toggle = EditorGUILayout.Toggle(toggle,;

I assume this means the default style for the toggle is not skin.toggle? Can I make this work without having to define I want the toggle style for the toggles?

(I’ve since noticed I seem to get the same problem with other controls, such as the textbox - buttons however seem to use the current skin by default as expected.)

A GUISkin only affects the runtime GUI controls (GUI / GUILayout). The editor controls (EditorGUI / EditorGUILayout) are just “extensions” of editor specific controls which do not use the

The editor controls use the EditorStyles class which is hardcoded. The members are read only properties which are directly used in the method overloads which do not explicitly take a GUIStyle.

So you have to pass your GUIStyle manually.

Keep in mind that EditorGUI and EditorGUILayout are just extensions of the ordinary GUI and GUILayout controls. They are not a replacement. You can still use GUILayout.Toggle inside editor code.

“EditorGUILayout.Toggle” is just a special editor / inspector version of the toggle.

So the short answer is you have to pass your style manually. However you should be able to just do this:

toggle = EditorGUILayout.Toggle(toggle, "toggle");

as long as you set your GUISkin to Unity has an implicit casting operator from string to GUIStyle. So whenever a GUIStyle is expected it looks up the string in the current skin. Even this works:

GUIStyle style = "button";

This way you can also look up custom style names defined in your skin.