void IPointerExitHandler.OnPointerExit(PointerEventData eventData)
 {
     m_pointerInside = false;
     if (!m_pointerDown)
     {
         m_cursorHelper.ResetCursor(this);
     }
 }
 void IPointerUpHandler.OnPointerUp(PointerEventData eventData)
 {
     m_pointerDown = false;
     if (!m_pointerInside)
     {
         CursorHelper.ResetCursor(this);
     }
 }
예제 #3
0
        private void OnItemEndDrag(object sender, ItemArgs e)
        {
            CursorHelper.ResetCursor(this);

            ProjectItemObjectPair objectItemPair = (ProjectItemObjectPair)e.Items[0];

            CompleteSpawn(objectItemPair);

            if (objectItemPair.IsResource)
            {
                DragDrop.RaiseDrop();
            }
        }
예제 #4
0
        private void OnItemDrop(object sender, ItemDropArgs e)
        {
            if (e.IsExternal)
            {
                return;
            }
            CursorHelper.ResetCursor(this);

            ProjectItemObjectPair objectItemPair = (ProjectItemObjectPair)e.DragItems[0];

            CompleteSpawn(objectItemPair);

            if (objectItemPair.IsResource)
            {
                DragDrop.RaiseDrop();
            }
        }
예제 #5
0
        protected override void UpdateOverride()
        {
            base.UpdateOverride();

            if (RuntimeTools.ActiveTool != null)
            {
                return;
            }

            HandleInput();

            if (RuntimeEditorApplication.IsPointerOverWindow(this))
            {
                SetCursor();
            }
            else
            {
                CursorHelper.ResetCursor(this);
            }
        }
예제 #6
0
        protected override void SetCursor()
        {
            if (!IPointerOverEditorArea)
            {
                CursorHelper.ResetCursor(this);
                return;
            }

            if (m_pan)
            {
                if (m_rotate && RuntimeTools.Current == RuntimeTool.View)
                {
                    CursorHelper.SetCursor(this, ViewTexture, new Vector2(0.5f, 0.5f), CursorMode.Auto);
                }
                else
                {
                    CursorHelper.SetCursor(this, MoveTexture, new Vector2(0.5f, 0.5f), CursorMode.Auto);
                }
            }
            else if (m_rotate)
            {
                CursorHelper.SetCursor(this, ViewTexture, new Vector2(0.5f, 0.5f), CursorMode.Auto);
            }
            else
            {
                if (RuntimeTools.Current == RuntimeTool.View)
                {
                    CursorHelper.SetCursor(this, MoveTexture, new Vector2(0.5f, 0.5f), CursorMode.Auto);
                }
                else
                {
                    bool rotate = InputController._GetKey(RotateKey) || InputController._GetKey(RotateKey2) || InputController._GetKey(RotateKey3);
                    if (!rotate)
                    {
                        CursorHelper.ResetCursor(this);
                    }
                }
            }
        }
예제 #7
0
        protected override void SetCursor()
        {
            if (!IPointerOverEditorArea)
            {
                CursorHelper.ResetCursor(this);
                return;
            }

            if (m_pan)
            {
                if (m_rotate && RuntimeTools.Current == RuntimeTool.View)
                {
                    CursorHelper.SetCursor(this, ViewTexture, ViewTexture != null ? new Vector2(ViewTexture.width / 2, ViewTexture.height / 2) : Vector2.zero, CursorMode.Auto);
                }
                else
                {
                    CursorHelper.SetCursor(this, MoveTexture, MoveTexture != null ? new Vector2(MoveTexture.width / 2, MoveTexture.height / 2) : Vector2.zero, CursorMode.Auto);
                }
            }
            else if (m_rotate)
            {
                CursorHelper.SetCursor(this, ViewTexture, ViewTexture != null ? new Vector2(ViewTexture.width / 2, ViewTexture.height / 2) : Vector2.zero, CursorMode.Auto);
            }
            else
            {
                if (RuntimeTools.Current == RuntimeTool.View)
                {
                    CursorHelper.SetCursor(this, MoveTexture, MoveTexture != null ? new Vector2(MoveTexture.width / 2, MoveTexture.height / 2) : Vector2.zero, CursorMode.Auto);
                }
                else
                {
                    bool rotate = InputController.GetKey(RotateKey) || InputController.GetKey(RotateKey2) || InputController.GetKey(RotateKey3);
                    if (!rotate)
                    {
                        CursorHelper.ResetCursor(this);
                    }
                }
            }
        }
예제 #8
0
        private void LateUpdate()
        {
            if (RuntimeTools.ActiveTool != null && RuntimeTools.ActiveTool != this)
            {
                return;
            }

            if (RuntimeTools.IsViewing)
            {
                return;
            }

            if (KeyCode == KeyCode.None || InputController.GetKeyDown(KeyCode))
            {
                m_active = true;
            }

            if (m_active)
            {
                if (Input.GetMouseButtonDown(MouseButton))
                {
                    m_startMousePosition = Input.mousePosition;
                    m_isDragging         = GetPoint(out m_startPt) &&
                                           (!RuntimeEditorApplication.IsOpened || RuntimeEditorApplication.IsPointerOverWindow(RuntimeWindowType.SceneView) && !RuntimeTools.IsPointerOverGameObject());
                    if (m_isDragging)
                    {
                        m_rectTransform.anchoredPosition = m_startPt;
                        m_rectTransform.sizeDelta        = new Vector2(0, 0);
                        CursorHelper.SetCursor(this, null, Vector3.zero, CursorMode.Auto);
                    }
                    else
                    {
                        RuntimeTools.ActiveTool = null;
                    }
                }
                else if (Input.GetMouseButtonUp(MouseButton))
                {
                    if (m_isDragging)
                    {
                        m_isDragging = false;

                        HitTest();
                        m_rectTransform.sizeDelta = new Vector2(0, 0);
                        CursorHelper.ResetCursor(this);
                    }

                    RuntimeTools.ActiveTool = null;
                    m_active = false;
                }
                else if (m_isDragging)
                {
                    GetPoint(out m_endPt);

                    Vector2 size = m_endPt - m_startPt;
                    if (size != Vector2.zero)
                    {
                        RuntimeTools.ActiveTool = this;
                    }
                    m_rectTransform.sizeDelta  = new Vector2(Mathf.Abs(size.x), Mathf.Abs(size.y));
                    m_rectTransform.localScale = new Vector3(Mathf.Sign(size.x), Mathf.Sign(size.y), 1);
                }
            }
        }
예제 #9
0
 void IPointerExitHandler.OnPointerExit(PointerEventData eventData)
 {
     CursorHelper.ResetCursor(this);
 }
예제 #10
0
        private void Update()
        {
            if (InputController._GetKeyDown(EnterPlayModeKey))
            {
                if (InputController._GetKey(ModifierKey))
                {
                    TogglePlayMode();
                }
            }

            if (IsInPlayMode)
            {
                return;
            }

            if (BoundingBoxSnapping != TogBoundingBoxSnap.isOn)
            {
                TogBoundingBoxSnap.isOn = BoundingBoxSnapping;
            }

            if (InputController._GetKeyDown(DuplicateKey))
            {
                if (InputController._GetKey(ModifierKey))
                {
                    Duplicate();
                }
            }
            else if (InputController._GetKeyDown(SnapToGridKey))
            {
                if (InputController._GetKey(ModifierKey))
                {
                    SnapToGrid();
                }
            }
            else if (InputController._GetKeyDown(DeleteKey))
            {
                Delete();
            }

            bool useSceneViewInput = SelectionController is RuntimeSceneView;

            if (!useSceneViewInput)
            {
                float wheel = InputController._GetAxis("Mouse ScrollWheel");
                if (wheel != 0.0f)
                {
#if UNITY_WEBGL
                    wheel *= 0.1f;
#endif
                    EditorCamera.orthographicSize -= wheel * EditorCamera.orthographicSize;
                    if (EditorCamera.orthographicSize < 0.2f)
                    {
                        EditorCamera.orthographicSize = 0.2f;
                    }
                    else if (EditorCamera.orthographicSize > 15)
                    {
                        EditorCamera.orthographicSize = 15;
                    }
                }

#if UNITY_WEBGL
                if (InputController._GetMouseButtonDown(1))
#else
                if (InputController._GetMouseButtonDown(1) || InputController._GetMouseButtonDown(2))
#endif
                {
                    m_dragPlane = new Plane(Vector3.up, m_pivot);
                    m_pan       = GetPointOnDragPlane(InputController._MousePosition, out m_prevMouse);
                    m_prevMouse = InputController._MousePosition;
                    CursorHelper.SetCursor(this, PanTexture, Vector2.zero, CursorMode.Auto);
                }
#if UNITY_WEBGL
                else if (InputController._GetMouseButton(1))
#else
                else if (InputController._GetMouseButton(1) || InputController._GetMouseButton(2))
#endif
                {
                    if (m_pan)
                    {
                        Vector3 pointOnDragPlane;
                        Vector3 prevPointOnDragPlane;
                        if (GetPointOnDragPlane(InputController._MousePosition, out pointOnDragPlane) &&
                            GetPointOnDragPlane(m_prevMouse, out prevPointOnDragPlane))
                        {
                            Vector3 dragOffset = (pointOnDragPlane - prevPointOnDragPlane);
                            m_prevMouse  = InputController._MousePosition;
                            m_panOffset -= dragOffset;
                            EditorCamera.transform.position -= dragOffset;
                        }
                    }
                }
#if UNITY_WEBGL
                else if (InputController._GetMouseButtonUp(1))
#else
                else if (InputController._GetMouseButtonUp(1) || InputController._GetMouseButtonUp(2))
#endif
                {
                    m_pan = false;
                    CursorHelper.ResetCursor(this);
                }

                if (InputController._GetKey(UpKey))
                {
                    Vector3 position = EditorCamera.transform.position;
                    position.y    += PanSpeed * Time.deltaTime;
                    m_panOffset.y += PanSpeed * Time.deltaTime;
                    EditorCamera.transform.position = position;
                }
                if (InputController._GetKey(DownKey))
                {
                    Vector3 position = EditorCamera.transform.position;
                    position.y    -= PanSpeed * Time.deltaTime;
                    m_panOffset.y -= PanSpeed * Time.deltaTime;
                    EditorCamera.transform.position = position;
                }
                if (InputController._GetKey(LeftKey))
                {
                    MoveMinZ();
                    MovePlusX();
                }
                if (InputController._GetKey(RightKey))
                {
                    MovePlusZ();
                    MoveMinX();
                }
                if (InputController._GetKey(FwdKey))
                {
                    MoveMinX();
                    MoveMinZ();
                }
                if (InputController._GetKey(BwdKey))
                {
                    MovePlusX();
                    MovePlusZ();
                }

                if (InputController._GetKeyDown(FocusKey))
                {
                    Focus();
                }
                else if (AutoFocus)
                {
                    do
                    {
                        if (RuntimeTools.ActiveTool != null)
                        {
                            break;
                        }

                        if (m_autoFocusTranform == null)
                        {
                            break;
                        }

                        if (m_autoFocusTranform.position == m_pivot)
                        {
                            break;
                        }

                        if (m_focusAnimations[0] == null || m_focusAnimations[0].InProgress)
                        {
                            break;
                        }

                        Vector3 offset = (m_autoFocusTranform.position - m_pivot) - m_panOffset;
                        EditorCamera.transform.position += offset;
                        m_pivot    += offset;
                        m_panOffset = Vector3.zero;
                    }while (false);
                }
            }

            if (RuntimeSelection.activeTransform != null)
            {
                Vector3 offset = Grid.GridOffset;
                offset.y        = RuntimeSelection.activeTransform.position.y;
                Grid.GridOffset = offset;
            }
        }
예제 #11
0
 public static void ResetCursor()
 {
     CursorHelper.ResetCursor(m_cursorLocker);
 }