1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-02-04 14:24:54 +08:00

Update NodeGraphEditor.cs

This commit is contained in:
MowfaqAlarbi 2019-09-04 16:45:48 +02:00 committed by GitHub
parent 0cf1a0d925
commit a6f0c9737a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEditor; using UnityEditor;
@ -42,7 +42,7 @@ namespace XNodeEditor {
} }
/// <summary> Add items for the context menu when right-clicking this node. Override to add custom menu items. </summary> /// <summary> Add items for the context menu when right-clicking this node. Override to add custom menu items. </summary>
public virtual void AddContextMenuItems(GenericMenu menu, GenericMenu.MenuFunction2 call = default(GenericMenu.MenuFunction2)) { public virtual void AddContextMenuItems(GenericMenu menu) {
Vector2 pos = NodeEditorWindow.current.WindowToGridPosition(Event.current.mousePosition); Vector2 pos = NodeEditorWindow.current.WindowToGridPosition(Event.current.mousePosition);
for (int i = 0; i < NodeEditorReflection.nodeTypes.Length; i++) { for (int i = 0; i < NodeEditorReflection.nodeTypes.Length; i++) {
Type type = NodeEditorReflection.nodeTypes[i]; Type type = NodeEditorReflection.nodeTypes[i];
@ -51,15 +51,9 @@ namespace XNodeEditor {
string path = GetNodeMenuName(type); string path = GetNodeMenuName(type);
if (string.IsNullOrEmpty(path)) continue; if (string.IsNullOrEmpty(path)) continue;
if(call != null) menu.AddItem(new GUIContent(path), false, () => {
menu.AddItem(new GUIContent(path), false, () => { CreateNode(type, pos);
CreateNode(type, pos); });
call(null);
});
else
menu.AddItem(new GUIContent(path), false, () => {
CreateNode(type, pos);
});
} }
menu.AddSeparator(""); menu.AddSeparator("");
if (NodeEditorWindow.copyBuffer != null && NodeEditorWindow.copyBuffer.Length > 0) menu.AddItem(new GUIContent("Paste"), false, () => NodeEditorWindow.current.PasteNodes(pos)); if (NodeEditorWindow.copyBuffer != null && NodeEditorWindow.copyBuffer.Length > 0) menu.AddItem(new GUIContent("Paste"), false, () => NodeEditorWindow.current.PasteNodes(pos));
@ -136,4 +130,4 @@ namespace XNodeEditor {
} }
} }
} }
} }