ContextMenu.ContextMenu 构造上下文菜单
static function ContextMenu (name : string) : ContextMenu
Description描述
Adds the function to the context menu of the component.
添加方法到组件的上下文菜单。
in the inspector of the attached script. When the user selects the context menu, the function will be executed.
在附加脚本的inspector(检视面板)。当用户选择上下文菜单时,这个方法将会被执行。
This is most useful for automatically setting up scene data from the script. The function has to be non-static.
这是非常有用的对于通过脚本自动设置场景数据。该函数必须是非静态的。
@ContextMenu ("Do Something")
function DoSomething () {
Debug.Log ("Perform operation");
}
// C# example:
class ContextTesting : MonoBehaviour {
/// Add a context menu named "Do Something" in the inspector
/// of the attached script.
///添加一个环境菜单名叫"Do Something"在添加了脚本的inspector(检视面板)
[ContextMenu ("Do Something")]
void DoSomething () {
Debug.Log ("Perform operation");
}
}
最后修改:2011年4月25日 Monday 20:48