完整方法:[MenuItem (itemName : string, isValidateFunction : bool, priority : int)]
参数itemName :路径名
参数isValidateFunction:是否判断运行条件 默认为false。 true时,需要重新加一个判断条件的函数
参数priority :组ID ,默认为1000,数值越小越靠前,10个为一组,会用小横线隔开
快捷键:
" %" 表示Ctrl cmd
" #" 表示shift
“ &” 表示alt
“ _字母” 表示单一按键
其他的一个键的支持情况: LEFT, RIGHT, UP, DOWN, F1 … F12, HOME, END, PGUP, PGDN
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class TestTool : MonoBehaviour
{
[MenuItem("我是菜单栏的/我是第一级/我是第二个", true)]
public static bool 我是第二个判断()
{
Debug.Log("我是第二个判断");
return Selection.objects.Length >= 3;
}
[MenuItem("我是菜单栏的/我是第一级/我是第二个 _b", false, 1)]
public static void 我是第二个()
{
Debug.Log("我是第二个");
}
[MenuItem("我是菜单栏的/我是第一级/我是第三个", false, 12)]
public static void 我是第三个()
Debug.Log("我是第三个");
}
}