/// <summary> Safely remove a node and all its connections. </summary> public void RemoveNode(XNode.INode node) { UnityEngine.Object.DestroyImmediate(node as UnityEngine.Object, true); Target.RemoveNode(node); if (NodeEditorPreferences.GetSettings().autoSave) { AssetDatabase.SaveAssets(); } }
/// <summary> Creates a copy of the original node in the graph </summary> public XNode.INode CopyNode(XNode.INode original) { var node = Target.CopyNode(original); node.Name = original.Name; if (NodeEditorPreferences.GetSettings().autoSave) { AssetDatabase.SaveAssets(); } return(node); }
/// <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) { // Actions if only one node is selected if (Selection.objects.Length == 1 && Selection.activeObject is XNode.INode) { XNode.INode node = Selection.activeObject as XNode.INode; menu.AddItem(new GUIContent("Move To Top"), false, () => NodeEditorWindow.current.MoveNodeToTop(node)); menu.AddItem(new GUIContent("Rename"), false, NodeEditorWindow.current.RenameSelectedNode); } // Add actions to any number of selected nodes menu.AddItem(new GUIContent("Duplicate"), false, NodeEditorWindow.current.DuplicateSelectedNodes); menu.AddItem(new GUIContent("Remove"), false, NodeEditorWindow.current.RemoveSelectedNodes); // Custom sctions if only one node is selected if (Selection.objects.Length == 1 && Selection.activeObject is XNode.INode) { XNode.INode node = Selection.activeObject as XNode.INode; NodeEditorWindow.AddCustomContextMenuItems(menu, node); } }