- Home /
EditorWindow Menu
Hi, How can I add this menu to my custom editor window?
I want use dropdown and toggle like this..
Answer by RobAnthem · Mar 19, 2017 at 08:22 PM
Those toggles are just buttons, you can easily do that with
bool myButton;
myButton = GUILayout.Button("Button");
if (myButton)
{
//do stuff
}
The dropdown is basic enum popup.
public enum YourEnum { Example1, Example2 }
public YourEnum myEnum;
void OnGUI
{
myEnum = EditorGUILayout.EnumPopup(myEnum);
if (myEnum == YourEnum.Example1)
{
//do stuff
}
}
And how it looks is a simple Toolbar editor style
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
// buttons and stuff go here.
EditorGUILayout.EndHorizontal();
No problem, the default EditorStyles also gives a lot of easy visual features, for example you can easily make a normal toggle also look like a button using something like EditorStyles.toolbarButton
and you can add an EditorStyle to any EditorGUI element, even GUILayout.Button
can take a Style parameter. As well, you can create custom styles using GUIStyle style = new GUIStyle();
then calling to the new style and altering parameters. I was planning on making an editor extension for creating styles visually at some point, if one doesn't exist.
Your answer
![](https://koobas.hobune.stream/wayback/20220612113518im_/https://answers.unity.com/themes/thub/images/avi.jpg)