public static ProxyNode Instance(bool isIn) { ProxyNode proxyNode = Node.Instance <ProxyNode>(); proxyNode.Init(isIn); return(proxyNode); }
internal override void WakeUp(Graph owner) { if (this.m_Slots == null) { this.m_Slots = new List <Slot>(); } if (this.m_SubGraph != null) { this.m_SubGraph.WakeUp(); } else { Debug.LogError("Subgraph is null????"); } if (this.m_SubGraph != null) { this.m_ProxyInNode = (ProxyNode)this.m_SubGraph.nodes.Find((Node n) => n is ProxyNode && ((ProxyNode)n).isIn); this.m_ProxyOutNode = (ProxyNode)this.m_SubGraph.nodes.Find((Node n) => n is ProxyNode && !((ProxyNode)n).isIn); } base.WakeUp(owner); }
public static GroupNode FromNodes(string name, List <Node> nodes, System.Type graphType) { if (nodes.Count == 0) { throw new ArgumentException("No nodes to group"); } Graph parentGraph = nodes[0].graph; if (parentGraph == null) { throw new ArgumentException("Nodes needs to be attached to a graph"); } GroupNode node = new GroupNode(name, parentGraph, graphType); parentGraph.AddNode(node); node.m_ProxyInNode = ProxyNode.Instance(true); node.subGraph.AddNode(node.m_ProxyInNode); node.m_ProxyOutNode = ProxyNode.Instance(false); node.subGraph.AddNode(node.m_ProxyOutNode); List <UnityEditor.Graphs.Edge> list = new List <UnityEditor.Graphs.Edge>(); foreach (Node node2 in nodes) { list.AddRange(node2.outputEdges); list.AddRange(node2.inputEdges); node.AddChildNode(node2); parentGraph.nodes.Remove(node2); } foreach (UnityEditor.Graphs.Edge edge in list) { if ((edge.fromSlot.node.graph == node.subGraph) && (edge.toSlot.node.graph == node.subGraph)) { if (!node.subGraph.Connected(edge.fromSlot, edge.toSlot)) { node.subGraph.Connect(edge.fromSlot, edge.toSlot); } } else if ((edge.fromSlot.node.graph == node.subGraph) && (edge.toSlot.node.graph != node.subGraph)) { string str = edge.fromSlot.name; int num = 0; while (node.m_ProxyInNode[str] != null) { str = edge.fromSlot.name + "_" + num++; } Slot s = new Slot(SlotType.InputSlot, str); node.m_ProxyInNode.AddSlot(s); node.subGraph.Connect(edge.fromSlot, s); Slot slot2 = new Slot(SlotType.OutputSlot, str); node.AddSlot(slot2); node.graph.Connect(slot2, edge.toSlot); } else if ((edge.fromSlot.node.graph != node.subGraph) && (edge.toSlot.node.graph == node.subGraph)) { string str2 = edge.toSlot.name; int num2 = 0; while (node.m_ProxyOutNode[str2] != null) { str2 = edge.toSlot.name + "_" + num2++; } Slot slot3 = new Slot(SlotType.OutputSlot, str2); node.m_ProxyOutNode.AddSlot(slot3); node.subGraph.Connect(slot3, edge.toSlot); Slot slot4 = new Slot(SlotType.InputSlot, str2); node.AddSlot(slot4); node.graph.Connect(edge.fromSlot, slot4); } node.graph.RemoveEdge(edge); } return(node); }
public static GroupNode FromNodes(string name, List <Node> nodes, Type graphType) { if (nodes.Count == 0) { throw new ArgumentException("No nodes to group"); } Graph graph = nodes[0].graph; if (graph == null) { throw new ArgumentException("Nodes needs to be attached to a graph"); } GroupNode groupNode = new GroupNode(name, graph, graphType); graph.AddNode(groupNode); groupNode.m_ProxyInNode = ProxyNode.Instance(true); groupNode.subGraph.AddNode(groupNode.m_ProxyInNode); groupNode.m_ProxyOutNode = ProxyNode.Instance(false); groupNode.subGraph.AddNode(groupNode.m_ProxyOutNode); List <Edge> list = new List <Edge>(); foreach (Node current in nodes) { list.AddRange(current.outputEdges); list.AddRange(current.inputEdges); groupNode.AddChildNode(current); graph.nodes.Remove(current); } foreach (Edge current2 in list) { if (current2.fromSlot.node.graph == groupNode.subGraph && current2.toSlot.node.graph == groupNode.subGraph) { if (!groupNode.subGraph.Connected(current2.fromSlot, current2.toSlot)) { groupNode.subGraph.Connect(current2.fromSlot, current2.toSlot); } } else if (current2.fromSlot.node.graph == groupNode.subGraph && current2.toSlot.node.graph != groupNode.subGraph) { string name2 = current2.fromSlot.name; int num = 0; while (groupNode.m_ProxyInNode[name2] != null) { name2 = current2.fromSlot.name + "_" + num++; } Slot slot = new Slot(SlotType.InputSlot, name2); groupNode.m_ProxyInNode.AddSlot(slot); groupNode.subGraph.Connect(current2.fromSlot, slot); Slot slot2 = new Slot(SlotType.OutputSlot, name2); groupNode.AddSlot(slot2); groupNode.graph.Connect(slot2, current2.toSlot); } else if (current2.fromSlot.node.graph != groupNode.subGraph && current2.toSlot.node.graph == groupNode.subGraph) { string name3 = current2.toSlot.name; int num2 = 0; while (groupNode.m_ProxyOutNode[name3] != null) { name3 = current2.toSlot.name + "_" + num2++; } Slot slot3 = new Slot(SlotType.OutputSlot, name3); groupNode.m_ProxyOutNode.AddSlot(slot3); groupNode.subGraph.Connect(slot3, current2.toSlot); Slot slot4 = new Slot(SlotType.InputSlot, name3); groupNode.AddSlot(slot4); groupNode.graph.Connect(current2.fromSlot, slot4); } groupNode.graph.RemoveEdge(current2); } return(groupNode); }