示例#1
0
        private void UpdateDragNode(BehaviorWindow window, Event currentEvent)
        {
            Vector2 mousePosition = window.WindowToGridPosition(currentEvent.mousePosition);

            for (int i = 0; i < Selection.objects.Length; ++i)
            {
                if (Selection.objects[i] is Node)
                {
                    Node       node       = Selection.objects[i] as Node;
                    int        nodeID     = node.GetInstanceID();
                    NodeEditor nodeEditor = window.behaviorGraphEditor.nodeEditors[nodeID];

                    Vector2 nodePosition = mousePosition + dragOffsets[i];

                    if (GRID_SNAP)
                    {
                        nodePosition = new Vector2(
                            Mathf.Round(nodePosition.x),
                            Mathf.Round(nodePosition.y)
                            );
                    }

                    nodeEditor.SetEditorPosition(nodePosition);
                    window.behaviorGraphEditor.RearrangeExecutionIndexes(node.input);
                }
            }

            window.Repaint();
        }
示例#2
0
        public void Update(BehaviorWindow window, Event currentEvent)
        {
            window.wantsMouseMove = true;
            switch (currentEvent.type)
            {
            case EventType.ScrollWheel:
                this.UpdateZoom(window, currentEvent);
                break;

            case EventType.MouseDrag:
                if (currentEvent.button == 0)
                {
                    if (this.draggingNode)
                    {
                        this.UpdateDragNode(window, currentEvent);
                    }
                    else if (this.draggingPort)
                    {
                        this.UpdateDragPort(window, currentEvent);
                    }
                }
                else if (currentEvent.button == 1 || currentEvent.button == 2)
                {
                    this.UpdatePan(window, currentEvent);
                }
                break;

            case EventType.MouseDown:
                this.UpdateMouseDown(window, currentEvent);
                window.Repaint();
                break;

            case EventType.MouseUp:
                this.UpdateMouseUp(window, currentEvent);
                window.Repaint();
                break;

            case EventType.ValidateCommand:
            case EventType.ExecuteCommand:
                this.UpdateCommands(window, currentEvent);
                break;
            }

            if (!HOVER_IS_TOOLBAR && !HOVER_IS_BLACKBOARD)
            {
                Vector2 position = currentEvent.mousePosition;
                MOUSE_POSITION = window.WindowToGridPosition(position);
            }
        }
示例#3
0
        // PRIVATE METHODS: -----------------------------------------------------------------------

        private void RecalculateDragOffsets(BehaviorWindow window, Event currentEvent)
        {
            this.dragOffsets = new Vector2[Selection.objects.Length];
            for (int i = 0; i < Selection.objects.Length; i++)
            {
                if (Selection.objects[i] is Node)
                {
                    Node node = Selection.objects[i] as Node;
                    this.dragOffsets[i] = node.position - window.WindowToGridPosition(currentEvent.mousePosition);
                }
                else
                {
                    this.dragOffsets[i] = Vector2.zero;
                }
            }
        }