// Constructor public NodeLink( Node fromNode, Outlet fromOutlet, Node toNode, Inlet toInlet ) { _fromNode = fromNode; _fromOutlet = fromOutlet; _toNode = toNode; _toInlet = toInlet; }
// Rescan the patch. public void Rescan() { _nodeList.Clear(); _instanceIDToNodeMap.Clear(); // Enumerate all the node instances. foreach (var i in _instance.GetComponentsInChildren<Wiring.NodeBase>()) { var node = new Node(i); _nodeList.Add(node); _instanceIDToNodeMap.Add(i.GetInstanceID(), node); } }
public WiringState(Node node, Outlet outlet) { this.node = node; this.outlet = outlet; }
public WiringState(Node node, Inlet inlet) { this.node = node; this.inlet = inlet; }
// Show the inlet/outlet context menu . void ShowNodeButtonMenu(Node node, Inlet inlet, Outlet outlet) { var menu = new GenericMenu(); if (inlet != null) { // "New Connection" menu.AddItem( new GUIContent("New Connection"), false, BeginWiring, new WiringState(node, inlet) ); // Disconnection items foreach (var targetNode in _patch.nodeList) { var link = targetNode.TryGetLinkTo(node, inlet, _patch); if (link == null) continue; var label = "Disconnect/" + targetNode.displayName; menu.AddItem(new GUIContent(label), false, RemoveLink, link); } } else { // "New Connection" menu.AddItem( new GUIContent("New Connection"), false, BeginWiring, new WiringState(node, outlet) ); // Disconnection items foreach (var link in node.EnumerateLinksFrom(outlet, _patch)) { var label = "Disconnect/" + link.toNode.displayName; menu.AddItem(new GUIContent(label), false, RemoveLink, link); } } menu.ShowAsContext(); }
public OutletButtonRecord(Node node, Outlet outlet) { this.node = node; this.outlet = outlet; }
public InletButtonRecord(Node node, Inlet inlet) { this.node = node; this.inlet = inlet; }
public DeleteNodeRecord(Node node) { this.node = node; }
// Add a node instance to the patch. public void AddNodeInstance(Wiring.NodeBase nodeInstance) { // Append to the hierarchy. nodeInstance.transform.parent = _instance.transform; // Register to this patch representation. var node = new Node(nodeInstance); _nodeList.Add(node); _instanceIDToNodeMap.Add(nodeInstance.GetInstanceID(), node); }
// Remove all links to a given node. public void RemoveLinksTo(Node targetNode, Patch patch) { if (_cachedLinks == null) CacheLinks(patch); foreach (var link in _cachedLinks) if (link.toNode == targetNode) RemoveLink(link.fromOutlet, link.toNode, link.toInlet); }
// Remove a link to a given node/inlet. public void RemoveLink(Outlet outlet, Node targetNode, Inlet inlet) { Undo.RecordObject(_instance, "Remove Link"); // Retrieve the target method (inlet) information. var targetMethod = targetNode._instance.GetType().GetMethod(inlet.methodName); // Remove the link. LinkUtility.RemoveLinkNodes( _instance, outlet.boundEvent, targetNode._instance, targetMethod ); // Clear the cache and update information. _cachedLinks = null; _serializedObject.Update(); }
// Try to make a link from the outlet to a given node/inlet. public void TryLinkTo(Outlet outlet, Node targetNode, Inlet inlet) { Undo.RecordObject(_instance, "Link To Node"); // Retrieve the target method (inlet) information. var targetMethod = targetNode._instance.GetType().GetMethod(inlet.methodName); // Try to create a link. var result = LinkUtility.TryLinkNodes( _instance, outlet.boundEvent, targetNode._instance, targetMethod ); // Clear the cache and update information. if (result) { _cachedLinks = null; _serializedObject.Update(); } }
// If this node has a link to a given inlet, return it. public NodeLink TryGetLinkTo(Node targetNode, Inlet inlet, Patch patch) { if (_cachedLinks == null) CacheLinks(patch); foreach (var link in _cachedLinks) if (link.toInlet == inlet) return link; return null; }