From f6404e9d9df75592b5bee8bc607a28343a23589c Mon Sep 17 00:00:00 2001 From: Thor Brigsted Date: Sun, 17 Feb 2019 03:18:49 +0100 Subject: [PATCH] Unity 5.3 support --- Scripts/Editor/Drawers/NodeEnumDrawer.cs | 9 +++++++++ Scripts/Editor/NodeEditorAction.cs | 12 ++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Scripts/Editor/Drawers/NodeEnumDrawer.cs b/Scripts/Editor/Drawers/NodeEnumDrawer.cs index 3e770f26..7478f94d 100644 --- a/Scripts/Editor/Drawers/NodeEnumDrawer.cs +++ b/Scripts/Editor/Drawers/NodeEnumDrawer.cs @@ -24,12 +24,21 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten string enumName = ""; if (property.enumValueIndex >= 0 && property.enumValueIndex < property.enumDisplayNames.Length) enumName = property.enumDisplayNames[property.enumValueIndex]; +#if UNITY_2017_1_OR_NEWER // Display dropdown if (EditorGUI.DropdownButton(position, new GUIContent(enumName), FocusType.Passive)) { // Position is all wrong if we show the dropdown during the node draw phase. // Instead, add it to onLateGUI to display it later. NodeEditorWindow.current.onLateGUI += () => ShowContextMenuAtMouse(property); } +#else + // Display dropdown + if (GUI.Button(position, new GUIContent(enumName), "MiniPopup")) { + // Position is all wrong if we show the dropdown during the node draw phase. + // Instead, add it to onLateGUI to display it later. + NodeEditorWindow.current.onLateGUI += () => ShowContextMenuAtMouse(property); + } +#endif EditorGUI.EndProperty(); } diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index 315f23ba..c436d330 100644 --- a/Scripts/Editor/NodeEditorAction.cs +++ b/Scripts/Editor/NodeEditorAction.cs @@ -289,7 +289,7 @@ public void Controls() { case EventType.KeyDown: if (EditorGUIUtility.editingTextField) break; else if (e.keyCode == KeyCode.F) Home(); - if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX) { + if (IsMac()) { if (e.keyCode == KeyCode.Return) RenameSelectedNode(); } else { if (e.keyCode == KeyCode.F2) RenameSelectedNode(); @@ -300,7 +300,7 @@ public void Controls() { if (e.commandName == "SoftDelete") { if (e.type == EventType.ExecuteCommand) RemoveSelectedNodes(); e.Use(); - } else if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX && e.commandName == "Delete") { + } else if (IsMac() && e.commandName == "Delete") { if (e.type == EventType.ExecuteCommand) RemoveSelectedNodes(); e.Use(); } else if (e.commandName == "Duplicate") { @@ -319,6 +319,14 @@ public void Controls() { } } + public bool IsMac() { +#if UNITY_2017_1_OR_NEWER + return SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX; +#else + return SystemInfo.operatingSystem.StartsWith("Mac"); +#endif + } + private void RecalculateDragOffsets(Event current) { dragOffset = new Vector2[Selection.objects.Length + selectedReroutes.Count]; // Selected nodes