Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

MenuItem priority hidden feature

Discussion in 'Documentation' started by Baste, Jun 1, 2016.

  1. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,224
    The MenuItem attribute has a priority argument, which defines the order in the submenu the menu item is placed in.

    What's not documented anywhere in the docs is that if the difference between two menu item's priority is greater than 10, a line will be added.

    This code:

    Code (csharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3.  
    4. public class TEST : MonoBehaviour {
    5.  
    6.     [MenuItem("TEST/1", false, 1)]
    7.     public static void TEST1() {
    8.        
    9.     }
    10.  
    11.     [MenuItem("TEST/11", false, 11)]
    12.     public static void TEST11() {
    13.  
    14.     }
    15.  
    16.     [MenuItem("TEST/12", false, 12)]
    17.     public static void TEST12() {
    18.        
    19.     }
    20. }
    Gives this result:
    11112.png

    While this code:

    Code (csharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3.  
    4. public class TEST : MonoBehaviour {
    5.  
    6.     [MenuItem("TEST/1", false, 1)]
    7.     public static void TEST1() {
    8.        
    9.     }
    10.  
    11.     [MenuItem("TEST/12", false, 12)]
    12.     public static void TEST12() {
    13.        
    14.     }
    15. }
    Gives this result:

    112.png


    The behaviour with the dividing lines should be documented, and the order of the default elements of all the lists should be documented, so we can know where our menu items gets placed.

    Information about what happens if two menu items have the same priority should also be included.

    Finally; why is the variable namesd "priority", when what the field defines is order?
     
    TimGS and Pulas like this.
  2. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    198
    That seems really arbitrary to me. Why not have a specific divider property? And this isn't the only poorly-named property we have either (RectTransform.sizeDelta, I am looking at you).

    Thanks for the report, I'll add it to be documented.