예제 #1
0
파일: NodeLink.cs 프로젝트: keijiro/OscKlak
 // Constructor
 public NodeLink(
     Node fromNode, Outlet fromOutlet,
     Node toNode, Inlet toInlet
 )
 {
     _fromNode = fromNode;
     _fromOutlet = fromOutlet;
     _toNode = toNode;
     _toInlet = toInlet;
 }
예제 #2
0
 public WiringState(Node node, Inlet inlet)
 {
     this.node = node;
     this.inlet = inlet;
 }
예제 #3
0
        // 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();
        }
예제 #4
0
 public InletButtonRecord(Node node, Inlet inlet)
 {
     this.node = node;
     this.inlet = inlet;
 }
 public WiringState(Node node, Inlet inlet)
 {
     this.node  = node;
     this.inlet = inlet;
 }
예제 #6
0
파일: Node.cs 프로젝트: keijiro/OscKlak
        // 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();
        }
예제 #7
0
파일: Node.cs 프로젝트: keijiro/OscKlak
        // 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();
            }
        }
예제 #8
0
파일: Node.cs 프로젝트: keijiro/OscKlak
        // 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;
        }