1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-03-26 22:49:02 +08:00

Added utility function that returns a prettified name for node type, also removed postfix 'Node' if it exists.

This commit is contained in:
Simon Rodriguez 2019-06-21 01:48:59 +02:00
parent 0553dc8894
commit 4fe5995c3d

View File

@ -133,6 +133,15 @@ namespace XNodeEditor {
} else return type.ToString();
}
/// <summary> Returns the default name for the node type. </summary>
public static string NodeDefaultName(Type type) {
string typeName = type.Name;
// Automatically remove redundant 'Node' postfix
if (typeName.EndsWith("Node")) typeName = typeName.Substring(0, typeName.LastIndexOf("Node"));
typeName = UnityEditor.ObjectNames.NicifyVariableName(typeName);
return typeName;
}
/// <summary>Creates a new C# Class.</summary>
[MenuItem("Assets/Create/xNode/Node C# Script", false, 89)]
private static void CreateNode() {