diff --git a/Scripts/Editor/NodeEditorAction.cs b/Scripts/Editor/NodeEditorAction.cs
index 1258983..3cb471b 100644
--- a/Scripts/Editor/NodeEditorAction.cs
+++ b/Scripts/Editor/NodeEditorAction.cs
@@ -301,7 +301,19 @@ namespace XNodeEditor {
public void CreateNode(Type type, Vector2 position) {
XNode.Node node = graph.AddNode(type);
node.position = position;
+
node.name = UnityEditor.ObjectNames.NicifyVariableName(type.ToString());
+
+ XNode.Node.CreateNodeMenuAttribute attrib;
+ if (NodeEditorUtilities.GetAttrib(type, out attrib))
+ {
+ if (attrib.UseLastAsName)
+ {
+ var subPaths = attrib.menuName.Split('/');
+ node.name = subPaths[subPaths.Length - 1];
+ }
+ }
+
AssetDatabase.AddObjectToAsset(node, graph);
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
Repaint();
diff --git a/Scripts/Node.cs b/Scripts/Node.cs
index be3d5a7..c034d07 100644
--- a/Scripts/Node.cs
+++ b/Scripts/Node.cs
@@ -239,10 +239,12 @@ namespace XNode {
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class CreateNodeMenuAttribute : Attribute {
public string menuName;
+ public bool UseLastAsName;
/// Manually supply node class with a context menu path
/// Path to this node in the context menu
- public CreateNodeMenuAttribute(string menuName) {
+ public CreateNodeMenuAttribute(string menuName, bool useLastAsName = false) {
this.menuName = menuName;
+ this.UseLastAsName = useLastAsName;
}
}