From c995bdf0bc2a3c0452366c6c6856663f5b0fd674 Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Mon, 12 Aug 2019 01:01:57 +0200 Subject: [PATCH] Added NodeEnumDrawer.EnumPopup so you can use it from your own node editor scripts --- Scripts/Editor/Drawers/NodeEnumDrawer.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Scripts/Editor/Drawers/NodeEnumDrawer.cs b/Scripts/Editor/Drawers/NodeEnumDrawer.cs index 7478f94..9ef1434 100644 --- a/Scripts/Editor/Drawers/NodeEnumDrawer.cs +++ b/Scripts/Editor/Drawers/NodeEnumDrawer.cs @@ -12,6 +12,12 @@ namespace XNodeEditor { public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); + EnumPopup(position, property, label); + + EditorGUI.EndProperty(); + } + + public static void EnumPopup(Rect position, SerializedProperty property, GUIContent label) { // Throw error on wrong type if (property.propertyType != SerializedPropertyType.Enum) { throw new ArgumentException("Parameter selected must be of type System.Enum"); @@ -39,10 +45,9 @@ namespace XNodeEditor { NodeEditorWindow.current.onLateGUI += () => ShowContextMenuAtMouse(property); } #endif - EditorGUI.EndProperty(); } - private void ShowContextMenuAtMouse(SerializedProperty property) { + private static void ShowContextMenuAtMouse(SerializedProperty property) { // Initialize menu GenericMenu menu = new GenericMenu(); @@ -57,7 +62,7 @@ namespace XNodeEditor { menu.DropDown(r); } - private void SetEnum(SerializedProperty property, int index) { + private static void SetEnum(SerializedProperty property, int index) { property.enumValueIndex = index; property.serializedObject.ApplyModifiedProperties(); property.serializedObject.Update();