/// <summary>
        /// Pans the camera based on user input.
        /// </summary>
        private void PanCameraBasedOnUserInput()
        {
            //added by me
            if (WereAnyUIElementsHovered())
            {
                return;
            }
            var blCameraPan = _cameraPanShortcut.IsActive() || toolBarController.isPanning;

            if (_mouse.WasMouseMovedSinceLastFrame && blCameraPan)
            //
            //if (_mouse.WasMouseMovedSinceLastFrame && _cameraPanShortcut.IsActive())
            {
                // Make sure all coroutines are stopped to avoid any conflicts
                StopAllCoroutines();

                // Pan based on the chosen pan mode
                if (_panSettings.PanMode == EditorCameraPanMode.Standard)
                {
                    float panSpeedTimesDeltaTime = Time.deltaTime * _panSettings.StandardPanSpeed;
                    EditorCameraPan.PanCamera(Camera,
                                              -_mouse.CursorOffsetSinceLastFrame.x * panSpeedTimesDeltaTime * (_panSettings.InvertXAxis ? -1.0f : 1.0f),
                                              -_mouse.CursorOffsetSinceLastFrame.y * panSpeedTimesDeltaTime * (_panSettings.InvertYAxis ? -1.0f : 1.0f));
                }
                else
                {
                    StartCoroutine(StartSmoothPan());
                }
            }
        }
        /// <summary>
        /// Starts a smooth pan operation.
        /// </summary>
        private IEnumerator StartSmoothPan()
        {
            // Calculate the camera initial speed and store the smooth value
            float panSpeedRightAxis = -_mouse.CursorOffsetSinceLastFrame.x * _panSettings.SmoothPanSpeed * (_panSettings.InvertXAxis ? -1.0f : 1.0f);
            float panSpeedUpAxis    = -_mouse.CursorOffsetSinceLastFrame.y * _panSettings.SmoothPanSpeed * (_panSettings.InvertYAxis ? -1.0f : 1.0f);
            float smoothValue       = _panSettings.SmoothValue;

            while (true)
            {
                // Pan the camera using the current speed along the camera right and up axes
                EditorCameraPan.PanCamera(Camera, panSpeedRightAxis * Time.deltaTime, panSpeedUpAxis * Time.deltaTime);

                // Move from the current speed towards 0 using the smooth value
                panSpeedRightAxis = Mathf.Lerp(panSpeedRightAxis, 0.0f, smoothValue);
                panSpeedUpAxis    = Mathf.Lerp(panSpeedUpAxis, 0.0f, smoothValue);

                // Exit if both speed values are small enough
                if (Mathf.Abs(panSpeedRightAxis) < 1e-5f && Mathf.Abs(panSpeedUpAxis) < 1e-5f)
                {
                    break;
                }

                // Wait for the next frame
                yield return(null);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Pans the camera based on user input.
        /// </summary>
        private void PanCameraBasedOnUserInput()
        {
            if (_mouse.WasMouseMovedSinceLastFrame && _cameraPanShortcut.IsActive())
            {
                // Make sure all coroutines are stopped to avoid any conflicts
                StopAllCoroutines();

                // Pan based on the chosen pan mode
                if (_panSettings.PanMode == EditorCameraPanMode.Standard)
                {
                    float panSpeedTimesDeltaTime = Time.deltaTime * _panSettings.StandardPanSpeed;
                    EditorCameraPan.PanCamera(Camera,
                                              -_mouse.CursorOffsetSinceLastFrame.x * panSpeedTimesDeltaTime * (_panSettings.InvertXAxis ? -1.0f : 1.0f),
                                              -_mouse.CursorOffsetSinceLastFrame.y * panSpeedTimesDeltaTime * (_panSettings.InvertYAxis ? -1.0f : 1.0f));
                }
                else
                {
                    StartCoroutine(StartSmoothPan());
                }
            }
        }