From 1691e4ce2130622a6b0047c967e2bb08b42c77ec Mon Sep 17 00:00:00 2001
From: Icarus <1375400884@qq.com>
Date: Tue, 26 Nov 2019 17:45:34 +0800
Subject: [PATCH] !W
---
Scripts/Editor/NodeEditor.cs | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/Scripts/Editor/NodeEditor.cs b/Scripts/Editor/NodeEditor.cs
index bdbbb86..ea07d45 100644
--- a/Scripts/Editor/NodeEditor.cs
+++ b/Scripts/Editor/NodeEditor.cs
@@ -148,6 +148,27 @@ namespace XNodeEditor {
return NodeEditorResources.styles.nodeBody;
}
+ /// Add items for the context menu when right-clicking this node. Override to add custom menu items.
+ public virtual void AddContextMenuItems(MenuPopupWindow menu) {
+ // Actions if only one node is selected
+ if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node) {
+ XNode.Node node = Selection.activeObject as XNode.Node;
+ menu.AddItem("Move To Top", () => NodeEditorWindow.current.MoveNodeToTop(node));
+ menu.AddItem("Rename", NodeEditorWindow.current.RenameSelectedNode);
+ }
+
+ // Add actions to any number of selected nodes
+ menu.AddItem("Copy", NodeEditorWindow.current.CopySelectedNodes);
+ menu.AddItem("Duplicate", NodeEditorWindow.current.DuplicateSelectedNodes);
+ menu.AddItem("Remove", NodeEditorWindow.current.RemoveSelectedNodes);
+
+ // Custom sctions if only one node is selected
+ if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node) {
+ XNode.Node node = Selection.activeObject as XNode.Node;
+ menu.AddCustomContextMenuItems(node);
+ }
+ }
+
/// Add items for the context menu when right-clicking this node. Override to add custom menu items.
public virtual void AddContextMenuItems(GenericMenu menu) {
// Actions if only one node is selected