UnityEditor.SceneViewMotion.HandleMouseUp C# (CSharp) Method

HandleMouseUp() private static method

private static HandleMouseUp ( SceneView view, int id, int button, int clickCount ) : void
view SceneView
id int
button int
clickCount int
return void
        private static void HandleMouseUp(SceneView view, int id, int button, int clickCount)
        {
            if (GUIUtility.hotControl == id)
            {
                RaycastHit hit;
                ResetDragState();
                if (((button == 2) && !s_Dragged) && RaycastWorld(Event.current.mousePosition, out hit))
                {
                    Vector3 vector = view.pivot - ((Vector3) ((view.rotation * Vector3.forward) * view.cameraDistance));
                    float size = view.size;
                    if (!view.orthographic)
                    {
                        size = (view.size * Vector3.Dot(hit.point - vector, (Vector3) (view.rotation * Vector3.forward))) / view.cameraDistance;
                    }
                    view.LookAt(hit.point, view.rotation, size);
                }
                Event.current.Use();
            }
        }

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.SceneViewMotion::HandleMouseUp