void Connect(IEdgeModel edgeModel, Unity.GraphElements.Port output, Unity.GraphElements.Port input) { var edge = new Edge(edgeModel); AddToGraphView(edge); edge.input = input; edge.output = output; edge.input.Connect(edge); edge.output.Connect(edge); m_GraphView.AddPositionDependency(edge.model); }
static void VisitNodes(Unity.GraphElements.Node node, ref HashSet <Unity.GraphElements.Node> visitedGraphElements) { if (node == null || visitedGraphElements == null || visitedGraphElements.Contains(node)) { return; } if (node is StackNode) { foreach (var visualElement in node.inputContainer.Children()) { var port = (Port)visualElement; if (port?.connections == null) { continue; } foreach (Unity.GraphElements.Edge connection in port.connections) { Unity.GraphElements.Port otherConnection = connection.output; Unity.GraphElements.Node otherNode = otherConnection?.node; if (otherNode == null) { continue; } visitedGraphElements.Add(otherNode); VisitNodes(otherNode, ref visitedGraphElements); } } } else { foreach (var visualElement in node.outputContainer.Children()) { var port = (Port)visualElement; if (port?.connections == null) { continue; } foreach (Unity.GraphElements.Edge connection in port.connections) { Unity.GraphElements.Port otherConnection = connection.input; Unity.GraphElements.Node otherNode = otherConnection?.node; if (otherNode == null) { continue; } visitedGraphElements.Add(otherNode); VisitNodes(otherNode, ref visitedGraphElements); } } } switch (node) { case FunctionNode functionNode: visitedGraphElements.Add(functionNode); break; case Node vsNode when vsNode.IsInStack: visitedGraphElements.Add(vsNode.Stack); break; } }