From 781128cc6e6d224834675926ee3acd236e8ba7b3 Mon Sep 17 00:00:00 2001 From: Simon Rodriguez Date: Fri, 21 Jun 2019 01:51:25 +0200 Subject: [PATCH] Use new NodeEditorUtilities.NodeDefaultName() --- Scripts/Editor/NodeEditor.cs | 2 +- Scripts/Editor/NodeGraphEditor.cs | 7 +------ Scripts/Editor/RenamePopup.cs | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs index c3f2f9e..76f4fe6 100644 --- a/Scripts/Editor/NodeEditor.cs +++ b/Scripts/Editor/NodeEditor.cs @@ -86,7 +86,7 @@ namespace XNodeEditor { /// Rename the node asset. This will trigger a reimport of the node. public void Rename(string newName) { - if (newName == null || newName.Trim() == "") newName = UnityEditor.ObjectNames.NicifyVariableName(target.GetType().Name); + if (newName == null || newName.Trim() == "") newName = NodeEditorUtilities.NodeDefaultName(target.GetType()); target.name = newName; AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target)); } diff --git a/Scripts/Editor/NodeGraphEditor.cs b/Scripts/Editor/NodeGraphEditor.cs index 8ece949..53efae9 100644 --- a/Scripts/Editor/NodeGraphEditor.cs +++ b/Scripts/Editor/NodeGraphEditor.cs @@ -74,12 +74,7 @@ namespace XNodeEditor { public virtual void CreateNode(Type type, Vector2 position) { XNode.Node node = target.AddNode(type); node.position = position; - if (string.IsNullOrEmpty(node.name)) { - // Automatically remove redundant 'Node' postfix - string typeName = type.Name; - if (typeName.EndsWith("Node")) typeName = typeName.Substring(0, typeName.LastIndexOf("Node")); - node.name = UnityEditor.ObjectNames.NicifyVariableName(typeName); - } + if (string.IsNullOrEmpty(node.name)) node.name = NodeEditorUtilities.NodeDefaultName(type); AssetDatabase.AddObjectToAsset(node, target); if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets(); NodeEditorWindow.RepaintAll(); diff --git a/Scripts/Editor/RenamePopup.cs b/Scripts/Editor/RenamePopup.cs index 9a1ed7b..3e98e2e 100644 --- a/Scripts/Editor/RenamePopup.cs +++ b/Scripts/Editor/RenamePopup.cs @@ -48,7 +48,7 @@ namespace XNodeEditor { // If input is empty, revert name to default instead if (input == null || input.Trim() == "") { if (GUILayout.Button("Revert to default") || (e.isKey && e.keyCode == KeyCode.Return)) { - target.name = UnityEditor.ObjectNames.NicifyVariableName(target.GetType().Name); + target.name = NodeEditorUtilities.NodeDefaultName(target.GetType()); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target)); Close(); }