本文整理汇总了C#中UnityEditor.SceneView.FixNegativeSize方法的典型用法代码示例。如果您正苦于以下问题:C# SceneView.FixNegativeSize方法的具体用法?C# SceneView.FixNegativeSize怎么用?C# SceneView.FixNegativeSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEditor.SceneView
的用法示例。
在下文中一共展示了SceneView.FixNegativeSize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleMouseDrag
private static void HandleMouseDrag(SceneView view, int id)
{
SceneViewMotion.s_Dragged = true;
if (GUIUtility.hotControl != id)
return;
Event current = Event.current;
switch (Tools.s_LockedViewTool)
{
case ViewTool.Orbit:
if (!view.in2DMode)
{
SceneViewMotion.OrbitCameraBehavior(view);
view.svRot.UpdateGizmoLabel(view, view.rotation * Vector3.forward, view.m_Ortho.target);
break;
}
break;
case ViewTool.Pan:
view.viewIsLockedToObject = false;
view.FixNegativeSize();
Vector3 vector3_1 = Camera.current.ScreenToWorldPoint(view.camera.WorldToScreenPoint(view.pivot) + new Vector3(-Event.current.delta.x, Event.current.delta.y, 0.0f)) - view.pivot;
if (current.shift)
vector3_1 *= 4f;
view.pivot += vector3_1;
break;
case ViewTool.Zoom:
float num = HandleUtility.niceMouseDeltaZoom * (!current.shift ? 3f : 9f);
if (view.orthographic)
{
view.size = Mathf.Max(0.0001f, view.size * (float) (1.0 + (double) num * (1.0 / 1000.0)));
break;
}
SceneViewMotion.s_TotalMotion += num;
view.size = (double) SceneViewMotion.s_TotalMotion >= 0.0 ? view.size + (float) ((double) num * (double) SceneViewMotion.s_ZoomSpeed * (3.0 / 1000.0)) : SceneViewMotion.s_StartZoom * (float) (1.0 + (double) SceneViewMotion.s_TotalMotion * (1.0 / 1000.0));
break;
case ViewTool.FPS:
if (!view.in2DMode)
{
if (!view.orthographic)
{
view.viewIsLockedToObject = false;
Vector3 vector3_2 = view.pivot - view.rotation * Vector3.forward * view.cameraDistance;
Quaternion rotation = view.rotation;
Quaternion quaternion1 = Quaternion.AngleAxis((float) ((double) current.delta.y * (3.0 / 1000.0) * 57.2957801818848), rotation * Vector3.right) * rotation;
Quaternion quaternion2 = Quaternion.AngleAxis((float) ((double) current.delta.x * (3.0 / 1000.0) * 57.2957801818848), Vector3.up) * quaternion1;
view.rotation = quaternion2;
view.pivot = vector3_2 + quaternion2 * Vector3.forward * view.cameraDistance;
}
else
SceneViewMotion.OrbitCameraBehavior(view);
view.svRot.UpdateGizmoLabel(view, view.rotation * Vector3.forward, view.m_Ortho.target);
break;
}
break;
default:
Debug.Log((object) "Enum value Tools.s_LockViewTool not handled");
break;
}
current.Use();
}
示例2: DoViewTool
public static void DoViewTool(SceneView view)
{
Event current = Event.current;
int viewToolId = SceneViewMotion.s_ViewToolID;
EventType typeForControl = current.GetTypeForControl(viewToolId);
if ((bool) ((Object) view) && Tools.s_LockedViewTool == ViewTool.FPS)
view.FixNegativeSize();
switch (typeForControl)
{
case EventType.MouseDown:
SceneViewMotion.HandleMouseDown(view, viewToolId, current.button);
break;
case EventType.MouseUp:
SceneViewMotion.HandleMouseUp(view, viewToolId, current.button, current.clickCount);
break;
case EventType.MouseDrag:
SceneViewMotion.HandleMouseDrag(view, viewToolId);
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 != viewToolId || (double) movementDirection.sqrMagnitude == 0.0)
break;
view.pivot = view.pivot + view.rotation * movementDirection;
view.Repaint();
break;
}
}
示例3: OrbitCameraBehavior
private static void OrbitCameraBehavior(SceneView view)
{
Event current = Event.current;
view.FixNegativeSize();
Quaternion target = view.m_Rotation.target;
Quaternion quaternion1 = Quaternion.AngleAxis((float) ((double) current.delta.y * (3.0 / 1000.0) * 57.2957801818848), target * Vector3.right) * target;
Quaternion quaternion2 = Quaternion.AngleAxis((float) ((double) current.delta.x * (3.0 / 1000.0) * 57.2957801818848), Vector3.up) * quaternion1;
if ((double) view.size < 0.0)
{
view.pivot = view.camera.transform.position;
view.size = 0.0f;
}
view.rotation = quaternion2;
}
示例4: OrbitCameraBehavior
private static void OrbitCameraBehavior(SceneView view)
{
Event current = Event.current;
view.FixNegativeSize();
Quaternion target = view.m_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 (view.size < 0f)
{
view.pivot = view.camera.transform.position;
view.size = 0f;
}
view.rotation = target;
}
示例5: HandleMouseDrag
private static void HandleMouseDrag(SceneView view, int id)
{
s_Dragged = true;
if (GUIUtility.hotControl != id)
{
return;
}
Event current = Event.current;
switch (Tools.s_LockedViewTool)
{
case ViewTool.Orbit:
if (!view.in2DMode && !view.isRotationLocked)
{
OrbitCameraBehavior(view);
view.svRot.UpdateGizmoLabel(view, (Vector3) (view.rotation * Vector3.forward), view.m_Ortho.target);
}
goto Label_031E;
case ViewTool.Pan:
{
view.viewIsLockedToObject = false;
view.FixNegativeSize();
Vector3 position = view.camera.WorldToScreenPoint(view.pivot) + new Vector3(-Event.current.delta.x, Event.current.delta.y, 0f);
Vector3 vector7 = Camera.current.ScreenToWorldPoint(position) - view.pivot;
vector7 = (Vector3) (vector7 * EditorGUIUtility.pixelsPerPoint);
if (current.shift)
{
vector7 = (Vector3) (vector7 * 4f);
}
view.pivot += vector7;
goto Label_031E;
}
case ViewTool.Zoom:
{
float num = HandleUtility.niceMouseDeltaZoom * (!current.shift ? ((float) 3) : ((float) 9));
if (!view.orthographic)
{
s_TotalMotion += num;
if (s_TotalMotion < 0f)
{
view.size = s_StartZoom * (1f + (s_TotalMotion * 0.001f));
}
else
{
view.size += (num * s_ZoomSpeed) * 0.003f;
}
}
else
{
view.size = Mathf.Max((float) 0.0001f, (float) (view.size * (1f + (num * 0.001f))));
}
goto Label_031E;
}
case ViewTool.FPS:
{
if (view.in2DMode || view.isRotationLocked)
{
goto Label_031E;
}
if (view.orthographic)
{
OrbitCameraBehavior(view);
break;
}
view.viewIsLockedToObject = false;
Vector3 vector = view.pivot - ((Vector3) ((view.rotation * Vector3.forward) * view.cameraDistance));
Quaternion rotation = view.rotation;
rotation = Quaternion.AngleAxis((current.delta.y * 0.003f) * 57.29578f, (Vector3) (rotation * Vector3.right)) * rotation;
rotation = Quaternion.AngleAxis((current.delta.x * 0.003f) * 57.29578f, Vector3.up) * rotation;
view.rotation = rotation;
view.pivot = vector + ((Vector3) ((rotation * Vector3.forward) * view.cameraDistance));
break;
}
default:
Debug.Log("Enum value Tools.s_LockViewTool not handled");
goto Label_031E;
}
view.svRot.UpdateGizmoLabel(view, (Vector3) (view.rotation * Vector3.forward), view.m_Ortho.target);
Label_031E:
current.Use();
}
示例6: DoViewTool
public static void DoViewTool(SceneView view)
{
Event current = Event.current;
int controlID = s_ViewToolID;
EventType typeForControl = current.GetTypeForControl(controlID);
if ((view != null) && (Tools.s_LockedViewTool == ViewTool.FPS))
{
view.FixNegativeSize();
}
switch (typeForControl)
{
case EventType.MouseDown:
HandleMouseDown(view, controlID, current.button);
break;
case EventType.MouseUp:
HandleMouseUp(view, controlID, current.button, current.clickCount);
break;
case EventType.MouseDrag:
HandleMouseDrag(view, controlID);
break;
case EventType.KeyDown:
HandleKeyDown(view);
break;
case EventType.KeyUp:
HandleKeyUp();
break;
case EventType.ScrollWheel:
HandleScrollWheel(view, !current.alt);
break;
case EventType.Layout:
{
Vector3 movementDirection = GetMovementDirection();
if ((GUIUtility.hotControl == controlID) && (movementDirection.sqrMagnitude != 0f))
{
view.pivot += view.rotation * movementDirection;
view.Repaint();
}
break;
}
}
}
示例7: HandleMouseDrag
private static void HandleMouseDrag(Transform cameraTransform, SceneView view, int id)
{
SceneViewMotion.s_Dragged = true;
if (GUIUtility.hotControl == id)
{
Event current = Event.current;
switch (Tools.s_LockedViewTool)
{
case ViewTool.Orbit:
if (!view.in2DMode)
{
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;
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)
{
if (!view.orthographic)
{
view.viewIsLockedToObject = false;
Quaternion quaternion = cameraTransform.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;
cameraTransform.rotation = quaternion;
}
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();
}
}
示例8: DoViewTool
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();
}
}