不解

MenuItem 菜单项


Inherits from System.Attribute

The MenuItem attribute allows you to add menu items to the main menu and inspector context menus.

MenuItem属性允许你添加菜单项到主菜单和检视面板上下文菜单。

Note: This is an editor class. To use it you have to place your script in Assets/Editor inside your project folder. Editor classes are in the UnityEditor namespace so for C# scripts you need to add "using UnityEditor;" at the beginning of the script.
注意:这是一个编辑器类,如果想使用它你需要把它放到工程目录下的Assets/Editor文件夹下。编辑器类在UnityEditor命名空间下。所以当使用C#脚本时,你需要在脚本前面加上 "using UnityEditor"引用。

The MenuItem attribute turns any static function into a menu command. Only static functions can use the MenuItem attribute.

MenuItem属性把任意静态函数变成为一个菜单命令。仅静态函数能使用这个MenuItem属性。

To create a hotkey you can use the following special characters: % (ctrl on Windows, cmd on OS X), # (shift), & (alt), _ (no key modifiers). For example to create a menu with hotkey shift-alt-g use "GameObject/Do Something #&g". To create a menu with hotkey g and no key modifiers pressed use "GameObject/Do Something _g". A hotkey text must be preceded with a space character ("GameObject/Do_g" won't be interpreted as hotkey, while "GameObject/Do _g" will).

可以使用一下指定字符创建快捷键:% (Windows上为ctrl, OS X上为cmd), # (shift), & (alt), _ (无修改键)。例如创建一个菜单快捷键为shift-alt-g使用GameObject/Do Something #&g。创建一个菜单快捷键g并没有修改键(组合键),使用GameObject/Do Something _g。快捷键文本必须在前面加一个空格字符(GameObject/Do_g不会被解释为快捷键,而是GameObject/Do _g这样,注意_g前面有空格)。

评论

热度(1)