ContextMenuConstructor

Switch to Manual
public ContextMenu (string itemName);
public ContextMenu (string itemName, bool isValidateFunction);
public ContextMenu (string itemName, bool isValidateFunction, int priority);

Parameters

itemName此上下文菜单项的名称。
isValidateFunction这是否为验证函数(默认为 false)。
priority优先级,用于重写菜单项的排序(默认为 1000000)。数字越低,其在该菜单中将越先显示。

Description

将此函数添加到该组件的上下文菜单。

在该附加脚本的 Inspector 中,当用户选择该上下文菜单时, 将执行此函数。

This is most useful for automatically setting up Scene data from the script. The function has to be non-static.

using UnityEngine;

public class ContextTesting : MonoBehaviour { /// Add a context menu named "Do Something" in the inspector /// of the attached script. [ContextMenu("Do Something")] void DoSomething() { Debug.Log("Perform operation"); } }