- Home /
MenuItem Priority is not being considered when itemName has a space
Hi,
I am not sure if this is a bug or not. I have a few menu items but for this test case let's consider I have two menu items.
I create them in different cs script files (all deriving from EditorWindow Class)
[MenuItem("Example/Something/item", false, 113)]
// function here
[MenuItem("Example/Some Other/item", false, 909)]
//function here
Once I save the script, I saw Some Other
first and then Something
under the Example menu without a divider in between them.
[MenuItem("Example/Something/item", false, 113)]
// function here
[MenuItem("Example/SomeOther/item", false, 909)]
//function here
By simply removing the space, I get the result I am looking for. Something
comes first and then a divider and then finally Some Other
is there.
Right now I have over 10 menu items, and I prioritize the child menu item by 0, 100, 200, 300 and etc.
I only have one itemName with space and that was the last on my list, 900, yet it kept appearing on the very top of the menu. Is it a bug or is it Unity's default behaviour? The only reference to Space Character in Unity's Documentation is that it is used for hotkeys.
Although I have never used $$anonymous$$enuItems after experimenting a little bit I figured out that it is best if don't use priority parameter but just the order you write each $$anonymous$$enuItem. So in your case just remove the priority parameters and see what happens. Again I have no experience over $$anonymous$$enuItems so I might be saying non-sense..
I have different parts of the game so the menu item gets created under different scripts. Once I removed the space Unity completely respects the priority and it appears just the way I want.
Answer by HenryStrattonFW · Jun 07, 2017 at 08:23 PM
Not tested this, but I imagine that perhaps the priority that you specify is only respected at the final level of the menu item, in your case there are 3 different levels at which that priority could apply so my guess would be that unity uses either execution order, alphabetical, or some other default ordering for all but the last layer at which the specified priority is then used?
Just a guess though.
Unity respects the priority once the space character is removed. I don't really want to change the execution order just to get the menu in grouped like I want to.
Your answer
Follow this Question
Related Questions
Having to press E thrice... 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
TextMeshPro Object not updating in real time 0 Answers
Stretched Particles Billboard 0 Answers