Can you make submenus in a GenericMenu?
I tried doing it “manually”:
GenericMenu GenerateMenu()
{
GenericMenu menu = new GenericMenu();
menu.AddItem(new GUIContent("Menu1"), false, new GenericMenu.MenuFunction(this.DoSubMenu));
return menu;
}
void DoSubMenu()
{
GenerateSubMenu().ShowAsContext();
}
GenericMenu GenerateSubMenu()
{
GenericMenu menu = new GenericMenu();
menu.AddItem(new GUIContent("SubMenu1"), false, new GenericMenu.MenuFunction(this.Test));
return menu;
}
void Test()
{
Debug.Log("TEST");
}
But I get a NullReferenceException on DoSubMenu(). Maybe it doesn’t like launching a menu before the other one is officially done…?
Is there another way to make custom menus in an EditorWindow?