// Constructor public NodeLink( Node fromNode, Outlet fromOutlet, Node toNode, Inlet toInlet ) { _fromNode = fromNode; _fromOutlet = fromOutlet; _toNode = toNode; _toInlet = toInlet; }
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 InletButtonRecord(Node node, Inlet inlet) { this.node = node; this.inlet = inlet; }
// 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; }