private static void HandleMouseDrag(SceneView view, int id)
{
SceneViewMotion.s_CurrentState = SceneViewMotion.MotionState.kDragging;
if (GUIUtility.hotControl == id)
{
Event current = Event.current;
switch (Tools.s_LockedViewTool)
{
case ViewTool.Orbit:
if (!view.in2DMode && !view.isRotationLocked)
{
SceneViewMotion.OrbitCameraBehavior(view);
view.svRot.UpdateGizmoLabel(view, view.rotation * Vector3.forward, view.m_Ortho.target);
}
break;
case ViewTool.Pan:
{
view.viewIsLockedToObject = false;
view.FixNegativeSize();
Camera camera = view.camera;
Vector3 vector = camera.WorldToScreenPoint(view.pivot);
vector += new Vector3(-Event.current.delta.x, Event.current.delta.y, 0f);
Vector3 vector2 = Camera.current.ScreenToWorldPoint(vector) - view.pivot;
vector2 *= EditorGUIUtility.pixelsPerPoint;
if (current.shift)
{
vector2 *= 4f;
}
view.pivot += vector2;
break;
}
case ViewTool.Zoom:
{
float num = HandleUtility.niceMouseDeltaZoom * (float)((!current.shift) ? 3 : 9);
if (view.orthographic)
{
view.size = Mathf.Max(0.0001f, view.size * (1f + num * 0.001f));
}
else
{
SceneViewMotion.s_TotalMotion += num;
if (SceneViewMotion.s_TotalMotion < 0f)
{
view.size = SceneViewMotion.s_StartZoom * (1f + SceneViewMotion.s_TotalMotion * 0.001f);
}
else
{
view.size += num * SceneViewMotion.s_ZoomSpeed * 0.003f;
}
}
break;
}
case ViewTool.FPS:
if (!view.in2DMode && !view.isRotationLocked)
{
if (!view.orthographic)
{
view.viewIsLockedToObject = false;
Vector3 a = view.pivot - view.rotation * Vector3.forward * view.cameraDistance;
Quaternion quaternion = view.rotation;
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;
view.rotation = quaternion;
view.pivot = a + quaternion * Vector3.forward * view.cameraDistance;
}
else
{
SceneViewMotion.OrbitCameraBehavior(view);
}
view.svRot.UpdateGizmoLabel(view, view.rotation * Vector3.forward, view.m_Ortho.target);
}
break;
default:
Debug.Log("Enum value Tools.s_LockViewTool not handled");
break;
}
current.Use();
}
}