目次
環境
- Unity 2019.4
サンプル集
MenuItem 属性の priority 引数に数字を与える。
[MenuItem("Tools/Window/Hoge", priority = 101)] private static void Hoge() { } [MenuItem("Tools/Window/Fuga", priority = 102)] private static void Fuga() {} [MenuItem("Tools/Window/Piyo", priority = 103)] private static void Piyo() {}
前の値より11以上離れてるとセパレーターが表示される。
[MenuItem("Tools/Window/Hoge", priority = 101)] private static void Hoge() { } [MenuItem("Tools/Window/Fuga", priority = 102)] private static void Fuga() {} [MenuItem("Tools/Window/Piyo", priority = 113)] private static void Piyo() {}
階層関係なく配下のpriorityを比較して、優先度が高い項目を持つノードが優先される。
[MenuItem("Tools/Window/Hoge", priority = 101)] private static void Hoge() { } [MenuItem("Tools/Window/Fuga", priority = 102)] private static void Fuga() {} [MenuItem("Tools/Window/Piyo", priority = 113)] private static void Piyo() {} [MenuItem("Tools/Settings/Language", priority = 121)] private static void Language() { } [MenuItem("Tools/Settings/Style", priority = 122)] private static void Style() { } [MenuItem("Tools/Settings/Utilities/Calculator", priority = 100)] private static void Calculator() { }
親ノードの属性でpriorityを付与しても、階層関係なくpriorityを比較されてしまうので効果なし。ついでに空の項目が生成される。
[MenuItem("Tools/Window/", priority = 130)] [MenuItem("Tools/Window/Hoge", priority = 101)] private static void Hoge() { } [MenuItem("Tools/Window/Fuga", priority = 102)] private static void Fuga() {} [MenuItem("Tools/Window/Piyo", priority = 113)] private static void Piyo() {} [MenuItem("Tools/Settings/Language", priority = 121)] private static void Language() { } [MenuItem("Tools/Settings/Style", priority = 122)] private static void Style() { } [MenuItem("Tools/Settings/Utilities/Calculator", priority = 123)] private static void Calculator() { }