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:
commit
6101b532bf
@ -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();
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user