コード例 #1
0
ファイル: GameView.cs プロジェクト: zlhtech/unity-decompiled
 internal Rect GetConstrainedGameViewRenderRect()
 {
     if ((UnityEngine.Object) this.m_Parent == (UnityEngine.Object)null)
     {
         return(GameView.s_MainGameViewRect);
     }
     this.m_Pos = this.m_Parent.borderSize.Remove(this.m_Parent.position);
     return(EditorGUIUtility.PixelsToPoints(GameView.GetConstrainedGameViewRenderRect(EditorGUIUtility.PointsToPixels(this.gameViewRenderRect), this.selectedSizeIndex)));
 }
コード例 #2
0
ファイル: GameView.cs プロジェクト: zhkuang/UnityDecompiled
 internal Rect GetConstrainedGameViewRenderRect()
 {
     if (this.m_Parent == null)
     {
         return(GameView.s_MainGameViewRect);
     }
     this.m_Pos = this.m_Parent.borderSize.Remove(this.m_Parent.position);
     return(GameView.GetConstrainedGameViewRenderRect(this.gameViewRenderRect, this.selectedSizeIndex));
 }
コード例 #3
0
        internal static Rect GetMainGameViewRenderRect()
        {
            GameView mainGameView = GameView.GetMainGameView();

            if (mainGameView != null)
            {
                GameView.s_MainGameViewRect = mainGameView.GetConstrainedGameViewRenderRect();
            }
            return(GameView.s_MainGameViewRect);
        }
コード例 #4
0
ファイル: GameView.cs プロジェクト: zlhtech/unity-decompiled
        internal static Rect GetMainGameViewRenderRect()
        {
            GameView mainGameView = GameView.GetMainGameView();

            if ((UnityEngine.Object)mainGameView != (UnityEngine.Object)null)
            {
                GameView.s_MainGameViewRect = mainGameView.GetConstrainedGameViewRenderRect();
            }
            return(GameView.s_MainGameViewRect);
        }
コード例 #5
0
        internal Rect GetConstrainedGameViewRenderRect()
        {
            if (this.m_Parent == null)
            {
                return(GameView.s_MainGameViewRect);
            }
            this.m_Pos = this.m_Parent.borderSize.Remove(this.m_Parent.position);
            Rect renderRect = EditorGUIUtility.PointsToPixels(this.gameViewRenderRect);
            Rect constrainedGameViewRenderRect = GameView.GetConstrainedGameViewRenderRect(renderRect, this.selectedSizeIndex);

            return(EditorGUIUtility.PixelsToPoints(constrainedGameViewRenderRect));
        }
コード例 #6
0
        private void OnGUI()
        {
            if (GameView.s_GizmoButtonStyle == null)
            {
                GameView.s_GizmoButtonStyle                 = "GV Gizmo DropDown";
                GameView.s_ResolutionWarningStyle           = new GUIStyle("PreOverlayLabel");
                GameView.s_ResolutionWarningStyle.alignment = TextAnchor.UpperLeft;
                GameView.s_ResolutionWarningStyle.padding   = new RectOffset(6, 6, 1, 1);
            }
            this.DoToolbarGUI();
            Rect gameViewRenderRect = this.gameViewRenderRect;
            Rect renderRect         = EditorGUIUtility.PointsToPixels(gameViewRenderRect);
            bool fitsInsideRect;
            Rect constrainedGameViewRenderRect = GameView.GetConstrainedGameViewRenderRect(renderRect, this.selectedSizeIndex, out fitsInsideRect);
            Rect rect       = EditorGUIUtility.PixelsToPoints(constrainedGameViewRenderRect);
            Rect rect2      = GUIClip.Unclip(rect);
            Rect cameraRect = EditorGUIUtility.PointsToPixels(rect2);

            base.SetInternalGameViewRect(rect2);
            EditorGUIUtility.AddCursorRect(rect, MouseCursor.CustomCursor);
            EventType type = Event.current.type;

            if (type == EventType.MouseDown && gameViewRenderRect.Contains(Event.current.mousePosition))
            {
                this.AllowCursorLockAndHide(true);
            }
            else if (type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
            {
                Unsupported.SetAllowCursorLock(false);
            }
            if (type == EventType.Repaint)
            {
                bool flag = EditorGUIUtility.IsDisplayReferencedByCameras(this.m_TargetDisplay);
                if (!this.currentGameViewSize.isFreeAspectRatio || !InternalEditorUtility.HasFullscreenCamera() || !flag)
                {
                    GUI.Box(gameViewRenderRect, GUIContent.none, "GameViewBackground");
                    if (!InternalEditorUtility.HasFullscreenCamera())
                    {
                        float[] array = new float[]
                        {
                            30f,
                            gameViewRenderRect.height / 2f - 10f,
                            gameViewRenderRect.height - 10f
                        };
                        for (int i = 0; i < array.Length; i++)
                        {
                            int num = (int)array[i];
                            GUI.Label(new Rect(gameViewRenderRect.width / 2f - 100f, (float)num, 300f, 20f), "Scene is missing a fullscreen camera", "WhiteLargeLabel");
                        }
                    }
                }
                Vector2 s_EditorScreenPointOffset = GUIUtility.s_EditorScreenPointOffset;
                GUIUtility.s_EditorScreenPointOffset = Vector2.zero;
                SavedGUIState savedGUIState = SavedGUIState.Create();
                if (this.ShouldShowMultiDisplayOption())
                {
                    EditorGUIUtility.RenderGameViewCamerasInternal(cameraRect, this.m_TargetDisplay, this.m_Gizmos, true);
                }
                else
                {
                    EditorGUIUtility.RenderGameViewCamerasInternal(cameraRect, 0, this.m_Gizmos, true);
                }
                GL.sRGBWrite = false;
                savedGUIState.ApplyAndForget();
                GUIUtility.s_EditorScreenPointOffset = s_EditorScreenPointOffset;
            }
            else if (type != EventType.Layout && type != EventType.Used)
            {
                if (WindowLayout.s_MaximizeKey.activated && (!EditorApplication.isPlaying || EditorApplication.isPaused))
                {
                    return;
                }
                bool flag2 = rect.Contains(Event.current.mousePosition);
                if (Event.current.rawType == EventType.MouseDown && !flag2)
                {
                    return;
                }
                Vector2 mousePosition = Event.current.mousePosition;
                Vector2 vector        = mousePosition - rect.position;
                vector = EditorGUIUtility.PointsToPixels(vector);
                Event.current.mousePosition = vector;
                Event.current.displayIndex  = this.m_TargetDisplay;
                EditorGUIUtility.QueueGameViewInputEvent(Event.current);
                bool flag3 = true;
                if (Event.current.rawType == EventType.MouseUp && !flag2)
                {
                    flag3 = false;
                }
                if (type == EventType.ExecuteCommand || type == EventType.ValidateCommand)
                {
                    flag3 = false;
                }
                if (flag3)
                {
                    Event.current.Use();
                }
                else
                {
                    Event.current.mousePosition = mousePosition;
                }
            }
            this.ShowResolutionWarning(new Rect(gameViewRenderRect.x, gameViewRenderRect.y, 200f, 20f), fitsInsideRect, constrainedGameViewRenderRect.size);
            if (this.m_Stats)
            {
                GameViewGUI.GameViewStatsGUI();
            }
        }
コード例 #7
0
        internal static Rect GetConstrainedGameViewRenderRect(Rect renderRect, int sizeIndex)
        {
            bool flag;

            return(GameView.GetConstrainedGameViewRenderRect(renderRect, sizeIndex, out flag));
        }
コード例 #8
0
 private void GameViewAspectWasChanged()
 {
     base.SetInternalGameViewRect(GameView.GetConstrainedGameViewRenderRect(this.gameViewRenderRect, this.selectedSizeIndex));
     EditorApplication.SetSceneRepaintDirty();
 }
コード例 #9
0
ファイル: GameView.cs プロジェクト: zlhtech/unity-decompiled
        internal static Rect GetConstrainedGameViewRenderRect(Rect renderRect, int sizeIndex)
        {
            bool fitsInsideRect;

            return(GameView.GetConstrainedGameViewRenderRect(renderRect, sizeIndex, out fitsInsideRect));
        }
コード例 #10
0
ファイル: GameView.cs プロジェクト: zhkuang/UnityDecompiled
        private void OnGUI()
        {
            if (GameView.s_GizmoButtonStyle == null)
            {
                GameView.s_GizmoButtonStyle                 = "GV Gizmo DropDown";
                GameView.s_ResolutionWarningStyle           = new GUIStyle("PreOverlayLabel");
                GameView.s_ResolutionWarningStyle.alignment = TextAnchor.UpperLeft;
                GameView.s_ResolutionWarningStyle.padding   = new RectOffset(6, 6, 1, 1);
            }
            this.DoToolbarGUI();
            Rect gameViewRenderRect = this.gameViewRenderRect;
            bool fitsInsideRect;
            Rect constrainedGameViewRenderRect = GameView.GetConstrainedGameViewRenderRect(gameViewRenderRect, this.selectedSizeIndex, out fitsInsideRect);
            Rect rect = GUIClip.Unclip(constrainedGameViewRenderRect);

            base.SetInternalGameViewRect(rect);
            EditorGUIUtility.AddCursorRect(constrainedGameViewRenderRect, MouseCursor.CustomCursor);
            EventType type = Event.current.type;

            if (type == EventType.MouseDown && gameViewRenderRect.Contains(Event.current.mousePosition))
            {
                Unsupported.SetAllowCursorLock(true);
                Unsupported.SetAllowCursorHide(true);
            }
            else
            {
                if (type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
                {
                    Unsupported.SetAllowCursorLock(false);
                }
            }
            if (type == EventType.Repaint)
            {
                if (!this.currentGameViewSize.isFreeAspectRatio || !InternalEditorUtility.HasFullscreenCamera())
                {
                    GUI.Box(gameViewRenderRect, GUIContent.none, "GameViewBackground");
                }
                Vector2 s_EditorScreenPointOffset = GUIUtility.s_EditorScreenPointOffset;
                GUIUtility.s_EditorScreenPointOffset = Vector2.zero;
                SavedGUIState savedGUIState = SavedGUIState.Create();
                if (Display.MultiDisplayLicense())
                {
                    EditorGUIUtility.RenderGameViewCameras(rect, this.m_TargetDisplay, this.m_Gizmos, true);
                }
                else
                {
                    EditorGUIUtility.RenderGameViewCameras(rect, 0, this.m_Gizmos, true);
                }
                savedGUIState.ApplyAndForget();
                GUIUtility.s_EditorScreenPointOffset = s_EditorScreenPointOffset;
            }
            else
            {
                if (type != EventType.Layout && type != EventType.Used)
                {
                    if (WindowLayout.s_MaximizeKey.activated && (!EditorApplication.isPlaying || EditorApplication.isPaused))
                    {
                        return;
                    }
                    bool flag = constrainedGameViewRenderRect.Contains(Event.current.mousePosition);
                    if (Event.current.rawType == EventType.MouseDown && !flag)
                    {
                        return;
                    }
                    Event.current.mousePosition = new Vector2(Event.current.mousePosition.x - constrainedGameViewRenderRect.x, Event.current.mousePosition.y - constrainedGameViewRenderRect.y);
                    EditorGUIUtility.QueueGameViewInputEvent(Event.current);
                    bool flag2 = true;
                    if (Event.current.rawType == EventType.MouseUp && !flag)
                    {
                        flag2 = false;
                    }
                    if (type == EventType.ExecuteCommand || type == EventType.ValidateCommand)
                    {
                        flag2 = false;
                    }
                    if (flag2)
                    {
                        Event.current.Use();
                    }
                    else
                    {
                        Event.current.mousePosition = new Vector2(Event.current.mousePosition.x + constrainedGameViewRenderRect.x, Event.current.mousePosition.y + constrainedGameViewRenderRect.y);
                    }
                }
            }
            this.ShowResolutionWarning(new Rect(gameViewRenderRect.x, gameViewRenderRect.y, 200f, 20f), fitsInsideRect, constrainedGameViewRenderRect.size);
            if (this.m_Stats)
            {
                GameViewGUI.GameViewStatsGUI();
            }
        }