using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; public class ContextMenuExample : EditorWindow { [MenuItem("ContextMenuExample/Open Window")] static void Open() { GetWindow().Show(); } private void OnGUI() { if(GUILayout.Button("DropDown", EditorStyles.popup)) { DropDownMenu(); } } void DropDownMenu() { GenericMenu menu = new GenericMenu(); menu.AddDisabledItem(new GUIContent("Do Nothing")); menu.AddSeparator(""); menu.AddItem(new GUIContent("SubMenu/Hello World"), false, HelloWorld); menu.AddItem(new GUIContent("SubMenu/Hello Parameters"), false, HelloParameters, new int[] { 1, 2, 3 }); menu.ShowAsContext(); } void HelloWorld() { Debug.Log("Hello World"); } void HelloParameters(object obj) { int[] parameters = (int[])obj; foreach (int i in parameters) Debug.Log("Parameter: " + i); } }