UnityEditor.SceneView.FixNegativeSize C# (CSharp) Method

FixNegativeSize() public method

public FixNegativeSize ( ) : void
return void
        public void FixNegativeSize()
        {
            float num = 90f;
            if (this.size < 0f)
            {
                float z = this.size / Mathf.Tan((num * 0.5f) * 0.01745329f);
                Vector3 vector = this.m_Position.value + (this.rotation * new Vector3(0f, 0f, -z));
                this.size = -this.size;
                z = this.size / Mathf.Tan((num * 0.5f) * 0.01745329f);
                this.m_Position.value = vector + (this.rotation * new Vector3(0f, 0f, z));
            }
        }

Usage Example

示例#1
0
        public static void DoViewTool(Transform cameraTransform, SceneView view)
        {
            Event     current        = Event.current;
            int       num            = SceneViewMotion.s_ViewToolID;
            EventType typeForControl = current.GetTypeForControl(num);
            float     d = 0f;

            if (view && Tools.s_LockedViewTool == ViewTool.FPS)
            {
                view.FixNegativeSize();
                d = (view.pivot - cameraTransform.position).magnitude;
            }
            switch (typeForControl)
            {
            case EventType.MouseDown:
                SceneViewMotion.HandleMouseDown(view, num, current.button);
                break;

            case EventType.MouseUp:
                SceneViewMotion.HandleMouseUp(view, num, current.button, current.clickCount);
                break;

            case EventType.MouseDrag:
                SceneViewMotion.HandleMouseDrag(cameraTransform, view, num);
                break;

            case EventType.KeyDown:
                SceneViewMotion.HandleKeyDown(view);
                break;

            case EventType.KeyUp:
                SceneViewMotion.HandleKeyUp();
                break;

            case EventType.ScrollWheel:
                SceneViewMotion.HandleScrollWheel(view, !current.alt);
                break;

            case EventType.Layout:
            {
                Vector3 movementDirection = SceneViewMotion.GetMovementDirection();
                if (GUIUtility.hotControl == num && movementDirection.sqrMagnitude != 0f)
                {
                    cameraTransform.position += cameraTransform.rotation * movementDirection;
                }
                break;
            }
            }
            if (view && Tools.s_LockedViewTool == ViewTool.FPS)
            {
                if (!view.orthographic)
                {
                    view.rotation = cameraTransform.rotation;
                }
                view.pivot = cameraTransform.position + cameraTransform.forward * d;
                view.Repaint();
            }
        }
All Usage Examples Of UnityEditor.SceneView::FixNegativeSize