ContextMenu 上下文菜单
Inherits from Attribute
The ContextMenu attribute allows you to add commands to the context menu
ContextMenu属性允许你去添加命令给上下文菜单
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");
}
}
Constructors构造器
-
Adds the function to the context menu of the component.
最后修改:2011年4月25日 Monday 20:32