Search Unity

Custom menu item in file menu (priority)

Discussion in 'Scripting' started by Kalidor, Jan 4, 2018.

  1. Kalidor

    Kalidor

    Joined:
    Sep 13, 2017
    Posts:
    14
    Hi!

    I want to add a custom menu item in the file menu below the "Build & Run" menu item (same group) in the Editor.

    upload_2018-1-4_8-41-31.png

    Which priority number is necessary to realize that?
     
    will_unity731 likes this.
  2. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    You can't. There's an internal version of the MenuItem attribute which accepts a final bool parameter of "InternalMenu". You can't set this value to true except in the UnityEditor assembly itself. I believe this is what sets certain menus to be listed first, no matter what priority they have (you can try int.MinValue if you like- it won't help).

    For the record, the "off limits" menus include the entire default File menu down to "Exit", about half of the Edit menu (everything above "Play", "Pause", and "Step"), and finally "About Unity" and "View License" in the Help menu. Everything else is fair game though.
     
  3. LiamAtDeepFreeze

    LiamAtDeepFreeze

    Joined:
    Sep 25, 2014
    Posts:
    1
    Super old post but for anyone else who stumbles upon this, it is 211

    Code (CSharp):
    1. [MenuItem("File/Build Thingy", priority = 211)]
    2. public static void Initialize()
    3. {
    4.            
    5. }
     
  4. OliverOlstar

    OliverOlstar

    Joined:
    Oct 1, 2020
    Posts:
    1
    Amazing!