- Home /
How are these mini-toolbars created?
Before anything, sorry if this has been already answered. I just don't know how to search for this, and I resorted to asking here after several attempts at googling for it.
Many panels in Unity have a cute mini-toolbar with filter fields, dropdown menus, and buttons, e.g. Project, Hierarchy, Scene, Console, etc.

I'm making an editor for a custom asset, and I'd like to know how they were implemented. I went through the scripting reference and I just couldn't find any component for it, and my searching Google was unsuccessful.
The custom asset I'm talking about is a dialogue asset with a not-so-simple object graph where this kind of toolbar for editing could come in very handy.
Any pointers will be appreciated.
Thanks!
Answer by BMayne · Sep 11, 2015 at 04:46 AM
There are also in EditorStyles.toolbar
Yes, you are right. We also can use EditorStyles.toolbar.
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
Answer by rutz · Sep 11, 2015 at 03:54 AM
You may already found the answer I guess but maybe someone still need it.
private bool collapsed = false;
private bool clearOnPlay = false;
public void OnGUI() {
EditorGUILayout.BeginHorizontal("Toolbar", GUILayout.ExpandWidth(true));
if (GUILayout.Button("Clear", "ToolbarButton", GUILayout.Width(45f))) {
Debug.Log("You click Clear button");
}
// Create space between Clear and Collapse button.
GUILayout.Space(5f);
// Create toggles button.
collapsed = GUILayout.Toggle(collapsed, "Collapse", "ToolbarButton");
clearOnPlay = GUILayout.Toggle(clearOnPlay, "Clear on Play", "ToolbarButton");
// Push content to be what they should be. (ex. width)
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
}
Your answer