/// <summary> Activates this graph's first node (either the StartNode or the EnterNode) </summary> public void ActivateStartOrEnterNode() { PreviousActiveNode = null; ActiveNode = GetStartOrEnterNode(); ActiveNode.SetActiveGraph(this); ActiveNode.OnEnter(null, null); // ActivateGlobalNodes(); }
/// <summary> Activate a Node </summary> /// <param name="nextActiveNode"> Target Node </param> /// <param name="connection"> Connection to ping (used as a visual cue in the editor) </param> public void SetActiveNode(Node nextActiveNode, Connection connection = null) { if (ActiveNode != null) { ActiveNode.OnExit(nextActiveNode, connection); ActiveNode.SetActiveGraph(null); } PreviousActiveNode = ActiveNode; if (InfiniteLoopDetected(nextActiveNode)) { throw new OverflowException("Nody detected an Infinite Loop." + "\n" + "This loop was detected in the '" + name + "' " + (m_isSubGraph ? "SubGraph" : "Graph") + ", at the '" + nextActiveNode.Name + "' Node. " + (PreviousActiveNode == null ? "" : "The connection that triggered this exception was between '" + PreviousActiveNode.Name + "' --and--> '" + nextActiveNode.Name + "' Nodes. ") + "This issue happened because the sockets are connected in such a manner that a closed infinite loop was created. " + "Please redesign the current UI flow to and from the '" + nextActiveNode.Name + "' Node, because Nody cannot automatically do that for you. " + "Look at how the '" + nextActiveNode.Name + "' Node is connected to other nodes and try to follow the UI flow in order to understand where the infinite loop happens. " + "If this exception were not in place, the Unity Editor would freeze, then you would have had to close it by force and lose any unsaved changes in the process." + "\n"); } ActiveNode = nextActiveNode; if (ActiveNode == null) { return; } if (ActiveNode.NodeType == NodeType.Exit) { DeactivateGlobalNodes(); //if the ActiveNode is an Exit Node -> then this means that this is a SubGraph that just finished it's cycle -> stop all of its GlobalNodes } ActiveNode.SetActiveGraph(this); ActiveNode.OnEnter(PreviousActiveNode, connection); }