Beispiel #1
0
        public virtual void Zoom()
        {
            Quaternion rotation = Quaternion.Euler(m_y, m_x, 0);

            transform.rotation = rotation;

            float mwheel = InputController._GetAxis("Mouse ScrollWheel");

            if (m_camera.orthographic)
            {
                m_camera.orthographicSize -= mwheel * m_camera.orthographicSize;
                if (m_camera.orthographicSize < 0.01f)
                {
                    m_camera.orthographicSize = 0.01f;
                }
            }

            Distance = Mathf.Clamp(Distance - mwheel * Mathf.Max(1.0f, Distance), DistanceMin, DistanceMax);
            Vector3 negDistance = new Vector3(0.0f, 0.0f, -Distance);
            Vector3 position    = rotation * negDistance + Target.position;

            transform.position = position;
        }
        private void Update()
        {
            if (WindowType == RuntimeWindowType.GameView)
            {
                if (RuntimeEditorApplication.GameCameras == null || RuntimeEditorApplication.GameCameras.Length == 0)
                {
                    return;
                }

                Rect cameraRect = RuntimeEditorApplication.GameCameras[0].pixelRect;
                UpdateState(cameraRect, true);
            }
            else if (WindowType == RuntimeWindowType.SceneView)
            {
                if (RuntimeEditorApplication.ActiveSceneCamera == null)
                {
                    if (Camera.main != null)
                    {
                        RuntimeEditorApplication.SceneCameras = new[] { Camera.main };
                    }
                    else
                    {
                        return;
                    }
                }

                Rect cameraRect = RuntimeEditorApplication.ActiveSceneCamera.pixelRect;
                UpdateState(cameraRect, false);
            }
            else if (WindowType == RuntimeWindowType.None)
            {
                if (Camera.main == null)
                {
                    return;
                }

                Rect cameraRect = Camera.main.pixelRect;
                UpdateState(cameraRect, false);
            }
            else if (WindowType == RuntimeWindowType.Other)
            {
                return;
            }
            else
            {
                if (m_isPointerOver)
                {
                    if (InputController._GetMouseButtonUp(0) ||
                        InputController._GetMouseButtonUp(1) ||
                        InputController._GetMouseButtonUp(2) ||
                        InputController._GetMouseButtonDown(0) ||
                        InputController._GetMouseButtonDown(1) ||
                        InputController._GetMouseButtonDown(2))
                    {
                        RuntimeEditorApplication.ActivateWindow(this);
                    }
                }
            }

            UpdateOverride();
        }