Пример #1
0
 // Constructor
 public NodeLink(
     Node fromNode, Outlet fromOutlet,
     Node toNode, Inlet toInlet
     )
 {
     _fromNode   = fromNode;
     _fromOutlet = fromOutlet;
     _toNode     = toNode;
     _toInlet    = toInlet;
 }
Пример #2
0
        // 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();
        }
Пример #3
0
        // Enumerate all the links from a given outlet.
        public NodeLink[] EnumerateLinksFrom(Outlet outlet, Patch patch)
        {
            if (_cachedLinks == null)
            {
                CacheLinks(patch);
            }

            var temp = new List <NodeLink>();

            foreach (var link in _cachedLinks)
            {
                if (link.fromOutlet == outlet)
                {
                    temp.Add(link);
                }
            }

            return(temp.ToArray());
        }
Пример #4
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();
        }
Пример #5
0
        // 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();
            }
        }
Пример #6
0
 public OutletButtonRecord(Node node, Outlet outlet)
 {
     this.node   = node;
     this.outlet = outlet;
 }
Пример #7
0
 public WiringState(Node node, Outlet outlet)
 {
     this.node   = node;
     this.outlet = outlet;
 }