代码:
[MenuItem("Tools/Delete ", true, 1)]
static bool DeleteVadidate()
{
if (Selection.gameObjects.Length > 0) return true;
else return false;
}
[MenuItem("Tools/Delete %d",false,1)]
static void Delete()
{
GameObject[] go = Selection.gameObjects;
foreach (GameObject g in go)
{
//GameObject.DestroyImmediate(g);
Undo.DestroyObjectImmediate(g);
}
}
注意:Tools/Delete与%d之间有一个空格。添加快捷键时:%代表Ctrl,#代表Shift,&代表Alt,_加符号则代表快捷键为该符号
上述添加的绿色代码实现了控制菜单项是否启用。