ContextMenu 属性用于向上下文菜单添加命令。
在该附加脚本的 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"); } }
ContextMenu | 将此函数添加到该组件的上下文菜单。 |