GenericMenu

class in UnityEditor

切换到手册

描述

GenericMenu 允许您创建自定义上下文菜单和下拉菜单。

下面的示例打开了一个带有按钮的编辑器窗口。单击该按钮可显示上下文菜单,您可以通过该菜单更改应用于窗口中 GUI 的颜色。将示例的内容复制到名为 GenericMenuExample.cs 的脚本中,然后将其置于您项目中的 Editor 文件夹内。

.

using UnityEngine;
using UnityEditor;

public class GenericMenuExample : EditorWindow { // open the window from the menu item Example -> GUI Color [MenuItem("Example/GUI