FixNegativeSize() public method

public FixNegativeSize ( ) : void
return void
Exemplo n.º 1
0
        private void HandleCameraMouseDrag(CameraState cameraState, Camera cam)
        {
            Event evt = Event.current;

            switch (m_CurrentViewTool)
            {
            case ViewTool.Orbit:
            {
                OrbitCameraBehavior(cameraState, cam);
            }
            break;

            case ViewTool.FPS:
            {
                Vector3 camPos = cameraState.pivot.value - cameraState.rotation.value * Vector3.forward * cameraState.GetCameraDistance();

                // Normal FPS camera behavior
                Quaternion rotation = cameraState.rotation.value;
                rotation = Quaternion.AngleAxis(evt.delta.y * .003f * Mathf.Rad2Deg, rotation * Vector3.right) * rotation;
                rotation = Quaternion.AngleAxis(evt.delta.x * .003f * Mathf.Rad2Deg, Vector3.up) * rotation;
                cameraState.rotation.value = rotation;
                cameraState.pivot.value    = camPos + rotation * Vector3.forward * cameraState.GetCameraDistance();
            }
            break;

            case ViewTool.Pan:
            {
                cameraState.FixNegativeSize();
                Vector3 screenPos = cam.WorldToScreenPoint(cameraState.pivot.value);
                screenPos += new Vector3(-Event.current.delta.x, Event.current.delta.y, 0);
                Vector3 worldDelta = cam.ScreenToWorldPoint(screenPos) - cameraState.pivot.value;
                if (evt.shift)
                {
                    worldDelta *= 4;
                }
                cameraState.pivot.value += worldDelta;
            }
            break;

            case ViewTool.Zoom:
            {
                float zoomDelta = HandleUtility.niceMouseDeltaZoom * (evt.shift ? 9 : 3);
                m_TotalMotion += zoomDelta;
                if (m_TotalMotion < 0)
                {
                    cameraState.viewSize.value = m_StartZoom * (1 + m_TotalMotion * .001f);
                }
                else
                {
                    cameraState.viewSize.value = cameraState.viewSize.value + zoomDelta * m_ZoomSpeed * .003f;
                }
            }
            break;

            default:
                break;
            }
            evt.Use();
        }
        private void HandleCameraMouseDrag(CameraState cameraState, Camera cam)
        {
            Event current = Event.current;

            switch (this.m_CurrentViewTool)
            {
            case ViewTool.Orbit:
                this.OrbitCameraBehavior(cameraState, cam);
                break;

            case ViewTool.Pan:
            {
                cameraState.FixNegativeSize();
                Vector3 vector = cam.WorldToScreenPoint(cameraState.pivot.value);
                vector += new Vector3(-Event.current.delta.x, Event.current.delta.y, 0f);
                Vector3 vector2 = cam.ScreenToWorldPoint(vector) - cameraState.pivot.value;
                if (current.shift)
                {
                    vector2 *= 4f;
                }
                cameraState.pivot.value += vector2;
                break;
            }

            case ViewTool.Zoom:
            {
                float num = HandleUtility.niceMouseDeltaZoom * (float)((!current.shift) ? 3 : 9);
                this.m_TotalMotion += num;
                if (this.m_TotalMotion < 0f)
                {
                    cameraState.viewSize.value = this.m_StartZoom * (1f + this.m_TotalMotion * 0.001f);
                }
                else
                {
                    cameraState.viewSize.value = cameraState.viewSize.value + num * this.m_ZoomSpeed * 0.003f;
                }
                break;
            }

            case ViewTool.FPS:
            {
                Vector3    a          = cameraState.pivot.value - cameraState.rotation.value * Vector3.forward * cameraState.GetCameraDistance();
                Quaternion quaternion = cameraState.rotation.value;
                quaternion = Quaternion.AngleAxis(current.delta.y * 0.003f * 57.29578f, quaternion * Vector3.right) * quaternion;
                quaternion = Quaternion.AngleAxis(current.delta.x * 0.003f * 57.29578f, Vector3.up) * quaternion;
                cameraState.rotation.value = quaternion;
                cameraState.pivot.value    = a + quaternion * Vector3.forward * cameraState.GetCameraDistance();
                break;
            }
            }
            current.Use();
        }
        private void HandleCameraMouseDrag(CameraState cameraState, Camera cam)
        {
            Event current = Event.current;

            switch (this.m_CurrentViewTool)
            {
            case UnityEditor.ViewTool.Orbit:
                this.OrbitCameraBehavior(cameraState, cam);
                break;

            case UnityEditor.ViewTool.Pan:
            {
                cameraState.FixNegativeSize();
                Vector3 position = cam.WorldToScreenPoint(cameraState.pivot.value) + new Vector3(-Event.current.delta.x, Event.current.delta.y, 0f);
                Vector3 vector7  = cam.ScreenToWorldPoint(position) - cameraState.pivot.value;
                if (current.shift)
                {
                    vector7 = (Vector3)(vector7 * 4f);
                }
                AnimVector3 pivot = cameraState.pivot;
                pivot.value += vector7;
                break;
            }

            case UnityEditor.ViewTool.Zoom:
            {
                float num = HandleUtility.niceMouseDeltaZoom * (!current.shift ? ((float)3) : ((float)9));
                this.m_TotalMotion += num;
                if (this.m_TotalMotion >= 0f)
                {
                    cameraState.viewSize.value += (num * this.m_ZoomSpeed) * 0.003f;
                    break;
                }
                cameraState.viewSize.value = this.m_StartZoom * (1f + (this.m_TotalMotion * 0.001f));
                break;
            }

            case UnityEditor.ViewTool.FPS:
            {
                Vector3    vector     = cameraState.pivot.value - ((Vector3)((cameraState.rotation.value * Vector3.forward) * cameraState.GetCameraDistance()));
                Quaternion quaternion = cameraState.rotation.value;
                quaternion = Quaternion.AngleAxis((current.delta.y * 0.003f) * 57.29578f, (Vector3)(quaternion * Vector3.right)) * quaternion;
                quaternion = Quaternion.AngleAxis((current.delta.x * 0.003f) * 57.29578f, Vector3.up) * quaternion;
                cameraState.rotation.value = quaternion;
                cameraState.pivot.value    = vector + ((Vector3)((quaternion * Vector3.forward) * cameraState.GetCameraDistance()));
                break;
            }
            }
            current.Use();
        }
Exemplo n.º 4
0
        private void OrbitCameraBehavior(CameraState cameraState, Camera cam)
        {
            Event evt = Event.current;

            cameraState.FixNegativeSize();
            Quaternion rotation = cameraState.rotation.target;

            rotation = Quaternion.AngleAxis(evt.delta.y * .003f * Mathf.Rad2Deg, rotation * Vector3.right) * rotation;
            rotation = Quaternion.AngleAxis(evt.delta.x * .003f * Mathf.Rad2Deg, Vector3.up) * rotation;
            if (cameraState.viewSize.value < 0)
            {
                cameraState.pivot.value    = cam.transform.position;
                cameraState.viewSize.value = 0;
            }
            cameraState.rotation.value = rotation;
        }
        private void OrbitCameraBehavior(CameraState cameraState, Camera cam)
        {
            Event current = Event.current;

            cameraState.FixNegativeSize();
            Quaternion target = cameraState.rotation.target;

            target = Quaternion.AngleAxis((current.delta.y * 0.003f) * 57.29578f, (Vector3)(target * Vector3.right)) * target;
            target = Quaternion.AngleAxis((current.delta.x * 0.003f) * 57.29578f, Vector3.up) * target;
            if (cameraState.viewSize.value < 0f)
            {
                cameraState.pivot.value    = cam.transform.position;
                cameraState.viewSize.value = 0f;
            }
            cameraState.rotation.value = target;
        }
 private void OrbitCameraBehavior(CameraState cameraState, Camera cam)
 {
     Event current = Event.current;
     cameraState.FixNegativeSize();
     Quaternion target = cameraState.rotation.target;
     target = Quaternion.AngleAxis((current.delta.y * 0.003f) * 57.29578f, (Vector3) (target * Vector3.right)) * target;
     target = Quaternion.AngleAxis((current.delta.x * 0.003f) * 57.29578f, Vector3.up) * target;
     if (cameraState.viewSize.value < 0f)
     {
         cameraState.pivot.value = cam.transform.position;
         cameraState.viewSize.value = 0f;
     }
     cameraState.rotation.value = target;
 }
        private void HandleCameraMouseDrag(CameraState cameraState, Camera cam)
        {
            Event current = Event.current;
            switch (this.m_CurrentViewTool)
            {
                case ViewTool.Orbit:
                    this.OrbitCameraBehavior(cameraState, cam);
                    break;

                case ViewTool.Pan:
                {
                    cameraState.FixNegativeSize();
                    Vector3 position = cam.WorldToScreenPoint(cameraState.pivot.value) + new Vector3(-Event.current.delta.x, Event.current.delta.y, 0f);
                    Vector3 vector7 = cam.ScreenToWorldPoint(position) - cameraState.pivot.value;
                    if (current.shift)
                    {
                        vector7 = (Vector3) (vector7 * 4f);
                    }
                    AnimVector3 pivot = cameraState.pivot;
                    pivot.value += vector7;
                    break;
                }
                case ViewTool.Zoom:
                {
                    float num = HandleUtility.niceMouseDeltaZoom * (!current.shift ? ((float) 3) : ((float) 9));
                    this.m_TotalMotion += num;
                    if (this.m_TotalMotion >= 0f)
                    {
                        cameraState.viewSize.value += (num * this.m_ZoomSpeed) * 0.003f;
                        break;
                    }
                    cameraState.viewSize.value = this.m_StartZoom * (1f + (this.m_TotalMotion * 0.001f));
                    break;
                }
                case ViewTool.FPS:
                {
                    Vector3 vector = cameraState.pivot.value - ((Vector3) ((cameraState.rotation.value * Vector3.forward) * cameraState.GetCameraDistance()));
                    Quaternion quaternion = cameraState.rotation.value;
                    quaternion = Quaternion.AngleAxis((current.delta.y * 0.003f) * 57.29578f, (Vector3) (quaternion * Vector3.right)) * quaternion;
                    quaternion = Quaternion.AngleAxis((current.delta.x * 0.003f) * 57.29578f, Vector3.up) * quaternion;
                    cameraState.rotation.value = quaternion;
                    cameraState.pivot.value = vector + ((Vector3) ((quaternion * Vector3.forward) * cameraState.GetCameraDistance()));
                    break;
                }
            }
            current.Use();
        }