UnityEditor.GameView.GetMainGameViewTargetSize C# (CSharp) Method

GetMainGameViewTargetSize() static private method

static private GetMainGameViewTargetSize ( ) : Vector2
return Vector2
        internal static Vector2 GetMainGameViewTargetSize()
        {
            GameView mainGameView = GetMainGameView();
            if ((mainGameView != null) && (mainGameView.m_Parent != null))
            {
                return mainGameView.targetSize;
            }
            return new Vector2(640f, 480f);
        }

Usage Example

Exemplo n.º 1
0
 public virtual void OnOverlayGUI(UnityEngine.Object target, SceneView sceneView)
 {
     if (!(target == null))
     {
         Camera  camera = (Camera)target;
         Vector2 mainGameViewTargetSize = GameView.GetMainGameViewTargetSize();
         if (mainGameViewTargetSize.x < 0f)
         {
             mainGameViewTargetSize.x = sceneView.position.width;
             mainGameViewTargetSize.y = sceneView.position.height;
         }
         Rect rect = camera.rect;
         mainGameViewTargetSize.x *= Mathf.Max(rect.width, 0f);
         mainGameViewTargetSize.y *= Mathf.Max(rect.height, 0f);
         if (mainGameViewTargetSize.x > 0f && mainGameViewTargetSize.y > 0f)
         {
             float num = mainGameViewTargetSize.x / mainGameViewTargetSize.y;
             mainGameViewTargetSize.y = 0.2f * sceneView.position.height;
             mainGameViewTargetSize.x = mainGameViewTargetSize.y * num;
             if (mainGameViewTargetSize.y > sceneView.position.height * 0.5f)
             {
                 mainGameViewTargetSize.y = sceneView.position.height * 0.5f;
                 mainGameViewTargetSize.x = mainGameViewTargetSize.y * num;
             }
             if (mainGameViewTargetSize.x > sceneView.position.width * 0.5f)
             {
                 mainGameViewTargetSize.x = sceneView.position.width * 0.5f;
                 mainGameViewTargetSize.y = mainGameViewTargetSize.x / num;
             }
             Rect rect2 = GUILayoutUtility.GetRect(mainGameViewTargetSize.x, mainGameViewTargetSize.y);
             if (Event.current.type == EventType.Repaint)
             {
                 this.previewCamera.CopyFrom(camera);
                 Skybox component = this.previewCamera.GetComponent <Skybox>();
                 if (component)
                 {
                     Skybox component2 = camera.GetComponent <Skybox>();
                     if (component2 && component2.enabled)
                     {
                         component.enabled  = true;
                         component.material = component2.material;
                     }
                     else
                     {
                         component.enabled = false;
                     }
                 }
                 RenderTexture previewTextureWithSize = this.GetPreviewTextureWithSize((int)rect2.width, (int)rect2.height);
                 previewTextureWithSize.antiAliasing = QualitySettings.antiAliasing;
                 this.previewCamera.targetTexture    = previewTextureWithSize;
                 this.previewCamera.pixelRect        = new Rect(0f, 0f, rect2.width, rect2.height);
                 Handles.EmitGUIGeometryForCamera(camera, this.previewCamera);
                 GL.sRGBWrite = (QualitySettings.activeColorSpace == ColorSpace.Linear);
                 this.previewCamera.Render();
                 GL.sRGBWrite = false;
                 Graphics.DrawTexture(rect2, previewTextureWithSize, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, GUI.color, EditorGUIUtility.GUITextureBlit2SRGBMaterial);
             }
         }
     }
 }
All Usage Examples Of UnityEditor.GameView::GetMainGameViewTargetSize