UnityEditor.HandleUtility.PopCamera C# (CSharp) Method

PopCamera() public static method

Retrieve all camera settings.

public static PopCamera ( Camera camera ) : void
camera UnityEngine.Camera
return void
        public static void PopCamera(Camera camera)
        {
            ((SavedCamera) s_SavedCameras.Pop()).Restore(camera);
        }

Usage Example

示例#1
0
 internal void OnGUI(SceneView view)
 {
     if (Mathf.Min(view.position.width, view.position.height) >= 100f)
     {
         if (Event.current.type == EventType.Repaint)
         {
             Profiler.BeginSample("SceneView.AxisSelector");
         }
         Camera camera = view.camera;
         HandleUtility.PushCamera(camera);
         if (camera.orthographic)
         {
             camera.orthographicSize = 0.5f;
         }
         camera.cullingMask        = 0;
         camera.transform.position = (Vector3)(camera.transform.rotation * new Vector3(0f, 0f, -5f));
         camera.clearFlags         = CameraClearFlags.Nothing;
         camera.nearClipPlane      = 0.1f;
         camera.farClipPlane       = 10f;
         camera.fieldOfView        = view.m_Ortho.Fade(70f, 0f);
         SceneView.AddCursorRect(new Rect((view.position.width - 100f) + 22f, 22f, 56f, 102f), MouseCursor.Arrow);
         Handles.SetCamera(new Rect(view.position.width - 100f, 0f, 100f, 100f), camera);
         Handles.BeginGUI();
         Rect position = new Rect((view.position.width - 100f) + 17f, 92f, 66f, 16f);
         if (!view.in2DMode && GUI.Button(position, string.Empty, styles.viewLabelStyleLeftAligned))
         {
             if (Event.current.button == 1)
             {
                 this.DisplayContextMenu(position, view);
             }
             else
             {
                 this.ViewSetOrtho(view, !view.orthographic);
             }
         }
         int   index = 8;
         Rect  rect2 = position;
         float num3  = 0f;
         float num4  = 0f;
         for (int i = 0; i < kDirNames.Length; i++)
         {
             if (i != index)
             {
                 num4 += this.dirNameVisible[i].faded;
                 if (this.dirNameVisible[i].faded > 0f)
                 {
                     num3 += styles.viewLabelStyleLeftAligned.CalcSize(EditorGUIUtility.TempContent(kDirNames[i])).x *this.dirNameVisible[i].faded;
                 }
             }
         }
         if (num4 > 0f)
         {
             num3 /= num4;
         }
         rect2.x += 37f - (num3 * 0.5f);
         rect2.x  = Mathf.RoundToInt(rect2.x);
         for (int j = 0; (j < this.dirNameVisible.Length) && (j < kDirNames.Length); j++)
         {
             if (j != index)
             {
                 Color color = Handles.centerColor;
                 color.a *= this.dirNameVisible[j].faded;
                 if (color.a > 0f)
                 {
                     GUI.color = color;
                     GUI.Label(rect2, kDirNames[j], styles.viewLabelStyleLeftAligned);
                 }
             }
         }
         Color centerColor = Handles.centerColor;
         centerColor.a *= this.faded2Dgray * this.m_Visible.faded;
         if (centerColor.a > 0f)
         {
             GUI.color = centerColor;
             GUI.Label(position, kDirNames[index], styles.viewLabelStyleCentered);
         }
         if (this.faded2Dgray < 1f)
         {
             this.DrawIsoStatusSymbol(new Vector3(rect2.x - 8f, rect2.y + 8.5f, 0f), view, 1f - this.faded2Dgray);
         }
         Handles.EndGUI();
         for (int k = 0; k < 3; k++)
         {
             Vector3 rhs = (Vector3)(kDirectionRotations[k] * Vector3.forward);
             this.dirVisible[k].target = Mathf.Abs(Vector3.Dot(camera.transform.forward, rhs)) < 0.9f;
         }
         float size = HandleUtility.GetHandleSize(Vector3.zero) * 0.2f;
         this.AxisSelectors(view, camera, size, -1f, styles.viewAxisLabelStyle);
         Color color3 = Color.Lerp(Handles.centerColor, Color.gray, this.faded2Dgray);
         color3.a *= this.m_Visible.faded;
         if (color3.a <= 0.1f)
         {
             GUI.enabled = false;
         }
         Handles.color = color3;
         if (Handles.Button(Vector3.zero, Quaternion.identity, size * 0.8f, size, new Handles.DrawCapFunction(Handles.CubeCap)) && !view.in2DMode)
         {
             if (Event.current.clickCount == 2)
             {
                 view.FrameSelected();
             }
             else if (Event.current.shift || (Event.current.button == 2))
             {
                 this.ViewFromNiceAngle(view, true);
             }
             else
             {
                 this.ViewSetOrtho(view, !view.orthographic);
             }
         }
         this.AxisSelectors(view, camera, size, 1f, styles.viewAxisLabelStyle);
         GUI.enabled = true;
         if (!view.in2DMode && (Event.current.type == EditorGUIUtility.swipeGestureEventType))
         {
             Vector3 up;
             Event   current = Event.current;
             if (current.delta.y > 0f)
             {
                 up = Vector3.up;
             }
             else if (current.delta.y < 0f)
             {
                 up = -Vector3.up;
             }
             else if (current.delta.x < 0f)
             {
                 up = Vector3.right;
             }
             else
             {
                 up = -Vector3.right;
             }
             Vector3 direction = -up - ((Vector3)(Vector3.forward * 0.9f));
             direction = view.camera.transform.TransformDirection(direction);
             float num9 = 0f;
             int   dir  = 0;
             for (int m = 0; m < 6; m++)
             {
                 float num12 = Vector3.Dot((Vector3)(kDirectionRotations[m] * -Vector3.forward), direction);
                 if (num12 > num9)
                 {
                     num9 = num12;
                     dir  = m;
                 }
             }
             this.ViewAxisDirection(view, dir);
             Event.current.Use();
         }
         HandleUtility.PopCamera(camera);
         Handles.SetCamera(camera);
         if (Event.current.type == EventType.Repaint)
         {
             Profiler.EndSample();
         }
     }
 }
All Usage Examples Of UnityEditor.HandleUtility::PopCamera