From 6c1af6f4cda16d50b80a970b803ebdd0549a448e Mon Sep 17 00:00:00 2001 From: Simon Rodriguez Date: Mon, 10 Dec 2018 23:33:25 +0100 Subject: [PATCH] Fix/error on duplicate (#82) * Pressing CTRL+D (duplicate) threw editorgui exception "Getting control 0s position in a group with only 3 controls when doing ValidateCommand". comparing to https://github.com/Unity-Technologies/UnityCsReference/blob/master/Editor/Mono/SceneHierarchyWindow.cs : row 211, the proper use of the event was not made. also fixed spelling of Dublicate to Duplicate. * Braces on wrong lines. * Something got wrong with the comments. --- Scripts/Editor/NodeEditorAction.cs | 18 +++++++++++++----- Scripts/Editor/NodeEditorGUI.cs | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs index 404b8af..b5315f8 100644 --- a/Scripts/Editor/NodeEditorAction.cs +++ b/Scripts/Editor/NodeEditorAction.cs @@ -278,9 +278,17 @@ namespace XNodeEditor { } break; case EventType.ValidateCommand: - if (e.commandName == "SoftDelete") RemoveSelectedNodes(); - else if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX && e.commandName == "Delete") RemoveSelectedNodes(); - else if (e.commandName == "Duplicate") DublicateSelectedNodes(); + case EventType.ExecuteCommand: + if (e.commandName == "SoftDelete") { + if (e.type == EventType.ExecuteCommand) RemoveSelectedNodes(); + e.Use(); + } else if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX && e.commandName == "Delete") { + if (e.type == EventType.ExecuteCommand) RemoveSelectedNodes(); + e.Use(); + } else if (e.commandName == "Duplicate") { + if (e.type == EventType.ExecuteCommand) DuplicateSelectedNodes(); + e.Use(); + } Repaint(); break; case EventType.Ignore: @@ -357,8 +365,8 @@ namespace XNodeEditor { } } - /// Dublicate selected nodes and select the dublicates - public void DublicateSelectedNodes() { + /// Duplicate selected nodes and select the duplicates + public void DuplicateSelectedNodes() { UnityEngine.Object[] newNodes = new UnityEngine.Object[Selection.objects.Length]; Dictionary substitutes = new Dictionary(); for (int i = 0; i < Selection.objects.Length; i++) { diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index 34fa6a7..8d7b95a 100644 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -126,7 +126,7 @@ namespace XNodeEditor { contextMenu.AddItem(new GUIContent("Rename"), false, RenameSelectedNode); } - contextMenu.AddItem(new GUIContent("Duplicate"), false, DublicateSelectedNodes); + contextMenu.AddItem(new GUIContent("Duplicate"), false, DuplicateSelectedNodes); contextMenu.AddItem(new GUIContent("Remove"), false, RemoveSelectedNodes); // If only one node is selected