Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
5
Question by Jeff Kingsley · Dec 01, 2010 at 04:30 PM · editorlayoutmenu-item

How does the priority of a Editor menuItem change item placement?

Referring to the MenuItem.MenuItem static function; According to the scripting reference manual, "Priority defines the order by which menu items are displayed in the menu bar.". Testing it with the following code does not seem to have any impact on the placement of the menu item.

public class MenuExtensions : MonoBehaviour {

[MenuItem ("File/LalaLand", false, 0)]
static void ColladaExtract() {
    Debug.Log("Doing extraction!");
}

}

Thanks!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

5 Replies

· Add your reply
  • Sort: 
avatar image
19
Best Answer

Answer by Jake-L · Mar 12, 2011 at 06:08 PM

This is what I found out while working with custom menus:

The MenuItem's are sorted in increasing order and if you add more then 10 between two items, an Separator-Line is drawn before the menuitem.

For example, see Unity's GameObject menu (I stripped syntax to just itemName,Priority):

  • GameObject/CreateEmpty,0
    • GameObject/Create Other/Particle System,1
    • GameObject/Create Other/Camera,2
  • GameObject/Center On Children/15

Cheers Jake

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image yoyo · Mar 23, 2015 at 01:49 AM 1
Share

Good sleuthing. I've also noticed that in the GameObject menu, priority -1000 puts items at the front (no surprise), and +1000 puts them at the end on the menu bar, but makes them disappear from the context menu. To complicate testing, the order may not be refreshed when code is recompiled, I need to close and reopen Unity to see the changes.

avatar image zwcloud · Dec 16, 2016 at 01:11 PM 0
Share

Great thanks to yoyo! It should be point out especially that the order may not be refreshed when code is recompiled, one need to close and reopen Unity to see the changes!

avatar image Hanh zwcloud · Feb 22, 2017 at 10:26 AM 0
Share

O$$anonymous$$G. Unbelievable. I can't believable that Unity Editor has that bug. I reopen Unity and it works like a charm. Thank zwcloud!

avatar image
2

Answer by Reapazor · Dec 14, 2010 at 04:32 AM

It groups similar numbers together, and it appears that those are relative to increments of 50.

0 1 2 3

50 51 52 53

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Jessy · Dec 01, 2010 at 07:13 PM

Unfortunately, it doesn't work (yet). I reported this bug on Christmas Eve of last year, and it's still open.

(Case 309855)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by lidapow · Sep 23, 2011 at 06:18 AM

Works

 @MenuItem("EventEditor/New", true)
 static function FileNew () {
     return EditorWindow.focusedWindow == EventEditorWindow.window;
 }

 @MenuItem("EventEditor/New", false, 10)
 static function FileNewPerform () {
     Debug.Log("Load");
 }

 @MenuItem("EventEditor/Open", true)
 static function FileOpen () {
     return EditorWindow.focusedWindow == EventEditorWindow.window;
 }

 @MenuItem("EventEditor/Open", false, 11)
 static function FileOpenPerform () {
     Debug.Log("Save");
 }

 @MenuItem("EventEditor/Save", true)
 static function FileSave () {
     return EditorWindow.focusedWindow == EventEditorWindow.window;
 }

 @MenuItem("EventEditor/Save", false, 30)
 static function FileSavePerform () {
     Debug.Log("Load");
 }

 @MenuItem("EventEditor/Save As", true)
 static function FileSaveAs () {
     return EditorWindow.focusedWindow == EventEditorWindow.window;
 }

 @MenuItem("EventEditor/Save As", false, 30)
 static function FileSaveAsPerform () {
     Debug.Log("Load");
 }    

 
 @MenuItem("EventEditor/Add/Entry", true)
 static function AddEntry () {
     return EditorWindow.focusedWindow == EventEditorWindow.window;
 }
 
 @MenuItem("EventEditor/Add/Entry")
 static function AddEntryPerform () {
     EventEditorWindow.window.CallbackPopup(0, ["Add", "Remove"]);
 }
 
 @MenuItem("EventEditor/Add/Trigger", true)
 static function AddTrigger () {
     return EditorWindow.focusedWindow == EventEditorWindow.window;
 }
 
 @MenuItem("EventEditor/Add/Trigger")
 static function AddTriggerPerform () {
     EventEditorWindow.window.CallbackPopup(1, ["Add", "Remove"]);
 }
 
 @MenuItem("EventEditor/Add/Terminal", true)
 static function AddTerminal () {
     return EditorWindow.focusedWindow == EventEditorWindow.window;
 }
 
 @MenuItem("EventEditor/Add/Terminal")
 static function AddTerminalPerform () {
     EventEditorWindow.window.CallbackPopup(2, ["Add", "Remove"]);
 }

MenuItem

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by lidapow · Sep 23, 2011 at 06:18 AM

It works

 @MenuItem("EventEditor/New", true)
 static function FileNew () {
     return EditorWindow.focusedWindow == EventEditorWindow.window;
 }
 @MenuItem("EventEditor/New", false, 10)
 static function FileNewPerform () {
     Debug.Log("Load");
 }
 @MenuItem("EventEditor/Open", true)
 static function FileOpen () {
     return EditorWindow.focusedWindow == EventEditorWindow.window;
 }
 @MenuItem("EventEditor/Open", false, 11)
 static function FileOpenPerform () {
     Debug.Log("Save");
 }
 @MenuItem("EventEditor/Save", true)
 static function FileSave () {
     return EditorWindow.focusedWindow == EventEditorWindow.window;
 }
 @MenuItem("EventEditor/Save", false, 30)
 static function FileSavePerform () {
     Debug.Log("Load");
 }
 @MenuItem("EventEditor/Save As", true)
 static function FileSaveAs () {
     return EditorWindow.focusedWindow == EventEditorWindow.window;
 }
 @MenuItem("EventEditor/Save As", false, 31)
 static function FileSaveAsPerform () {
     Debug.Log("Load");
 }    


alt text

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Separator in custom Editor MenuItem 1 Answer

How would you go about showing an editor preferences panel in the inspector? 1 Answer

Inspector look changed 0 Answers

Editor Menu Item open Window 2 Answers

Is it possible to set the editor layout through the command line for debugging? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges