- Home /
How do I add a MenuItem to Hierarchy's Create Menu?
Hi to all,
Seems like a really simple one I can't find an answer to anywhere…
[ MenuItem( "MyMenu/MyWindow" ) ] //creates a new menu tab
[ MenuItem( "Assets/Create/MyAsset" ) ] //Adds to the project window's create menu
[ MenuItem( "Hierarchy/Create/MyObjInTheScene" ) ] //Nope ( also creates a general menu tab, called "Hierarchy" )
I've also tried "Scene/" and "/", and running out of ideas.
Many thanks for your help,
Gregzo
Thank you, make that an answer so that I can accept, up vote, and lick my screen in joy! Why isn't this in the docs?
Answer by Fr0stbite · Mar 23, 2014 at 01:37 PM
[ MenuItem( "GameObject/Create Other/Your Object" ) ]
Licked! Quick note: Create Other, the space does matter. Thanks a lot,
G
Answer by CodeRonnie · Oct 09, 2015 at 09:48 AM
Sorry to necro this, but I found this question before finding a more up-to-date answer in the docs by searching the keywords of the accepted answer. From the documentation as of now in case anyone else ends up here:
...note that in order for a menu item in "GameObject/" to be propagated to the hierarchy Create dropdown and hierarchy context menu, it must be grouped with the other GameObject creation menu items. This can be achieved by setting its priority to 10 (see example below). Note that for legacy purposes MenuItems in "GameObject/Create Other" with no explicit priority set will receive a priority of 10 instead of the default 1000 - we encourage using a more descriptive category name than "Create Other" and explicitly setting the priority to 10.
With that it seems impossible to add separators into the sub menu, right?
I agree with above but it was missing a link to the documentation so:
https://docs.unity3d.com/ScriptReference/$$anonymous$$enuItem.html
Your answer
Follow this Question
Related Questions
(Editor) How to add Checkmarks to MenuItems 4 Answers
Get all items from hierarchy? 2 Answers
Gibt es eine Lösung/Einstellung für: Hierarchy Custom / My Sort? 1 Answer
How set order in [MenuItem] attribute like in [CreateAssetMenu] attribute? 2 Answers
Determine the Scene that is selected when using context menu 0 Answers