private void UpdateNodesActiveNode() { if (!EditorApplication.isPlaying) { if (CurrentGraph == null || CurrentGraph.ActiveNode == null) { return; } NodesGUIsDatabase[CurrentGraph.ActiveNode.Id].IsActive = false; CurrentGraph.SetActiveNode(null); return; } foreach (BaseNodeGUI nodeGUI in NodesGUIsDatabase.Values) { nodeGUI.IsActive = CurrentGraph.ActiveNode == nodeGUI.Node; } }
/// <summary> Show a context menu over a node. Shown when the developer right clicks over a node's header, footer or any parts of its body, except the sockets, the connection points and any other buttons </summary> /// <param name="node"> Target node </param> private void ShowNodeContextMenu(Node node) { var menu = new GenericMenu(); //create a generic menu if (EditorApplication.isPlaying) { menu.AddItem(new GUIContent(UILabels.SetActiveNode), false, () => { CurrentGraph.SetActiveNode(node); }); //Set Active Node menu.AddSeparator(""); } menu.AddItem(new GUIContent(UILabels.Center), false, () => { CenterSelectedNodesInWindow(); }); //Center Node menu.AddSeparator(""); menu.AddItem(new GUIContent(UILabels.Disconnect), false, () => { if (WindowSettings.SelectedNodes.Count > 0) { // if (ActiveSelection.Nodes.Count > 0) ClearNodesConnections(WindowSettings.SelectedNodes, true); //Disconnect all selected nodes } else { ClearNodeConnections(node, true); //Disconnect Node } }); menu.AddSeparator(""); var copyNode = new GUIContent(UILabels.Copy); var deleteNode = new GUIContent(UILabels.Delete); if (node.CanBeDeleted) { menu.AddItem(copyNode, false, () => { ExecuteGraphAction(GraphAction.Copy); }); //Copy Node menu.AddItem(deleteNode, false, () => { ExecuteGraphAction(GraphAction.DeleteNodes); }); //Delete Node } else { menu.AddDisabledItem(copyNode); //Copy Node label menu.AddDisabledItem(deleteNode); //Delete Node label } menu.ShowAsContext(); //show menu at mouse position }