UnityEditor.SceneViewMotion.HandleMouseDown C# (CSharp) Method

HandleMouseDown() private static method

private static HandleMouseDown ( SceneView view, int id, int button ) : void
view SceneView
id int
button int
return void
        private static void HandleMouseDown(SceneView view, int id, int button)
        {
            s_Dragged = false;
            if (Tools.viewToolActive)
            {
                ViewTool viewTool = Tools.viewTool;
                if (Tools.s_LockedViewTool != viewTool)
                {
                    Event current = Event.current;
                    GUIUtility.hotControl = id;
                    Tools.s_LockedViewTool = viewTool;
                    s_StartZoom = view.size;
                    s_ZoomSpeed = Mathf.Max(Mathf.Abs(s_StartZoom), 0.3f);
                    s_TotalMotion = 0f;
                    if (view != null)
                    {
                        view.Focus();
                    }
                    if (Toolbar.get != null)
                    {
                        Toolbar.get.Repaint();
                    }
                    EditorGUIUtility.SetWantsMouseJumping(1);
                    current.Use();
                    GUIUtility.ExitGUI();
                }
            }
        }

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::HandleMouseDown