mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-21 01:36:03 +08:00
Automatically remove "Node" postfix from creation menu
This commit is contained in:
parent
650522223c
commit
788b8d8a0b
@ -150,6 +150,15 @@ namespace XNodeEditor {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
/// <summary> Returns the default creation path for the node type. </summary>
|
||||
public static string NodeDefaultPath(Type type) {
|
||||
string typePath = type.ToString().Replace('.', '/');
|
||||
// Automatically remove redundant 'Node' postfix
|
||||
if (typePath.EndsWith("Node")) typePath = typePath.Substring(0, typePath.LastIndexOf("Node"));
|
||||
typePath = UnityEditor.ObjectNames.NicifyVariableName(typePath);
|
||||
return typePath;
|
||||
}
|
||||
|
||||
/// <summary>Creates a new C# Class.</summary>
|
||||
[MenuItem("Assets/Create/xNode/Node C# Script", false, 89)]
|
||||
private static void CreateNode() {
|
||||
|
||||
@ -38,7 +38,7 @@ namespace XNodeEditor {
|
||||
if (NodeEditorUtilities.GetAttrib(type, out attrib)) // Return custom path
|
||||
return attrib.menuName;
|
||||
else // Return generated path
|
||||
return ObjectNames.NicifyVariableName(type.ToString().Replace('.', '/'));
|
||||
return NodeEditorUtilities.NodeDefaultPath(type);
|
||||
}
|
||||
|
||||
/// <summary> Add items for the context menu when right-clicking this node. Override to add custom menu items. </summary>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user