예제 #1
0
            public void ProcessNodeInput(Node node, int inputId, Rect bigRect, Rect smallRect)
            {
                Event     currentEvent = Event.current;
                EventType eventType    = currentEvent.type;

                if (_node != null)//draging
                {
                    if (!bigRect.Contains(currentEvent.mousePosition))
                    {
                        return;
                    }
                    Link link = node.Inputs[inputId];


                    bool validate = NodeCollector.ValidateTypes(link.Type, _node.CashedOutputType) || NodeCollector.ValidateTypes(_node.CashedOutputType, link.Type);
                    if (eventType == EventType.Repaint && validate)
                    {
                        _hoverInput    = true;
                        _inputPosition = GetNodeInputPosition(node, inputId);
                    }

                    if (eventType == EventType.MouseUp && currentEvent.button == 0)
                    {
                        Undo.RecordObject(Window._nodeDataContainer, "Change Link");
                        if (validate)
                        {
                            link.NodeId = _node.NodeId;
                        }
                    }
                }
                else//
                {
                    if (eventType == EventType.MouseDown && currentEvent.button == 0 && smallRect.Contains(currentEvent.mousePosition))
                    {
                        Link link   = node.Inputs[inputId];
                        Node inNode = Window._nodeData.GetNode(link);
                        if (inNode != null)
                        {
                            Undo.RecordObject(Window._nodeDataContainer, "Change Link");
                            _node       = inNode;
                            link.NodeId = Node.NoNodeID;

                            DefaultNode.ToDefault(link, Window._nodeData);

                            _hoverInput = false;
                            Window.RebuildGraph();
                            currentEvent.Use();
                        }
                    }
                }
            }