コード例 #1
0
ファイル: ZNode.cs プロジェクト: ZenCoderGames/ZAI
        public void ProcessEvents(Event e)
        {
            for (int i = 0; i < _connectorList.Count; ++i)
            {
                _connectorList[i].ProcessEvents(e);
            }

            switch (e.type)
            {
            case EventType.MouseDown:
                if (_isSelected)
                {
                    NodeEditor.DeselectNode(this);
                }
                _isSelected = false;
                _isDragging = false;
                if (e.button == 0)
                {
                    if (_scaledWindowRect.Contains(e.mousePosition))
                    {
                        if (_outConnector == null || !_outConnector.IsSelected)
                        {
                            _isDragging        = true;
                            GUI.changed        = true;
                            _dragStartPosition = e.mousePosition;
                            if (!_nodeTree.IsNodeInSelectedGroup(this))
                            {
                                _nodeTree.ClearSelectedGroup();
                            }
                        }
                        e.Use();
                    }
                }
                break;

            case EventType.MouseUp:
                if (_isDragging)
                {
                    if (e.button == 0)
                    {
                        if (_scaledWindowRect.Contains(e.mousePosition))
                        {
                            if (Vector2.Distance(_dragStartPosition, e.mousePosition) < 10)
                            {
                                _isSelected = true;
                                NodeTree.DeselectOtherNodes(this);
                                NodeEditor.SelectNode(this);
                            }
                            e.Use();
                            NodeEditor.DragNodeCompleted();
                        }
                    }
                }
                _isDragging = false;
                break;

            case EventType.MouseDrag:
                if (e.button == 0 && _isDragging)
                {
                    if (_nodeTree.IsNodeInSelectedGroup(this))
                    {
                        _nodeTree.DragSelectedNodes(e.delta);
                    }
                    else
                    {
                        Drag(e.delta);
                    }
                    e.Use();
                }
                break;
            }
        }