- Home /
Question by
nunoh123 · Sep 17, 2013 at 09:18 AM ·
editorwindowtoggletoolbar
Unity Editor Window Toolbar
How can i make a toggle button in an editor window toolbar like the "Clear on play" button of the console window. My code for the toolbar looks like this: GUILayout.BeginHorizontal(EditorStyles.toolbar);
if (GUILayout.Button("Clear All", EditorStyles.toolbarButton)) {
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
Comment
Answer by Matthew Miner · Jan 28, 2014 at 01:37 AM
Use GUILayout.Toggle. EditorGUILayout.Toggle, which seems like the more obvious choice, is difficult to style correctly.
bool someOption;
void OnGUI ()
{
GUILayout.BeginHorizontal(EditorStyles.toolbar);
someOption = GUILayout.Toggle(someOption, "Toggle Me", EditorStyles.toolbarButton);
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613114327im_/https://answers.unity.com/themes/thub/images/avi.jpg)