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

Merge f7bfe3e6949cafa8c6354b27eebeee255f3e6538 into 97ec4bbf42000f8a5517c8f92486c5b7f5404bd8

This commit is contained in:
Joram Vandemoortele 2018-05-12 12:44:36 +00:00 committed by GitHub
commit 6101b532bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -301,7 +301,19 @@ namespace XNodeEditor {
public void CreateNode(Type type, Vector2 position) { public void CreateNode(Type type, Vector2 position) {
XNode.Node node = graph.AddNode(type); XNode.Node node = graph.AddNode(type);
node.position = position; node.position = position;
node.name = UnityEditor.ObjectNames.NicifyVariableName(type.ToString()); 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); AssetDatabase.AddObjectToAsset(node, graph);
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets(); if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
Repaint(); Repaint();

View File

@ -239,10 +239,12 @@ namespace XNode {
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class CreateNodeMenuAttribute : Attribute { public class CreateNodeMenuAttribute : Attribute {
public string menuName; public string menuName;
public bool UseLastAsName;
/// <summary> Manually supply node class with a context menu path </summary> /// <summary> Manually supply node class with a context menu path </summary>
/// <param name="menuName"> Path to this node in the context menu </param> /// <param name="menuName"> Path to this node in the context menu </param>
public CreateNodeMenuAttribute(string menuName) { public CreateNodeMenuAttribute(string menuName, bool useLastAsName = false) {
this.menuName = menuName; this.menuName = menuName;
this.UseLastAsName = useLastAsName;
} }
} }