UnityEditor.GameView.OnGUI C# (CSharp) Method

OnGUI() private method

private OnGUI ( ) : void
return void
        private void OnGUI()
        {
            if ((base.position.size * EditorGUIUtility.pixelsPerPoint) != this.m_LastWindowPixelSize)
            {
                this.UpdateZoomAreaAndParent();
            }
            this.DoToolbarGUI();
            this.CopyDimensionsToParentView();
            EditorGUIUtility.AddCursorRect(this.viewInWindow, MouseCursor.CustomCursor);
            EventType type = Event.current.type;
            if ((type == EventType.MouseDown) && this.viewInWindow.Contains(Event.current.mousePosition))
            {
                this.AllowCursorLockAndHide(true);
            }
            else if ((type == EventType.KeyDown) && (Event.current.keyCode == KeyCode.Escape))
            {
                Unsupported.SetAllowCursorLock(false);
            }
            bool flag = EditorApplication.isPlaying && !EditorApplication.isPaused;
            this.m_ZoomArea.hSlider = !flag && (this.m_ZoomArea.shownArea.width < this.targetInContent.width);
            this.m_ZoomArea.vSlider = !flag && (this.m_ZoomArea.shownArea.height < this.targetInContent.height);
            this.m_ZoomArea.enableMouseInput = !flag;
            this.ConfigureZoomArea();
            if (flag)
            {
                GUIUtility.keyboardControl = 0;
            }
            Vector2 mousePosition = Event.current.mousePosition;
            Vector2 vector2 = this.WindowToGameMousePosition(mousePosition);
            GUI.color = Color.white;
            EventType type2 = Event.current.type;
            this.m_ZoomArea.BeginViewGUI();
            switch (type)
            {
                case EventType.Layout:
                case EventType.Used:
                    break;

                case EventType.Repaint:
                {
                    GUI.Box(this.m_ZoomArea.drawRect, GUIContent.none, Styles.gameViewBackgroundStyle);
                    Vector2 vector3 = GUIUtility.s_EditorScreenPointOffset;
                    GUIUtility.s_EditorScreenPointOffset = Vector2.zero;
                    SavedGUIState state = SavedGUIState.Create();
                    this.ConfigureTargetTexture((int) this.targetSize.x, (int) this.targetSize.y);
                    if (this.m_ClearInEditMode && !EditorApplication.isPlaying)
                    {
                        this.ClearTargetTexture();
                    }
                    int targetDisplay = 0;
                    if (this.ShouldShowMultiDisplayOption())
                    {
                        targetDisplay = this.m_TargetDisplay;
                    }
                    if (this.m_TargetTexture.IsCreated())
                    {
                        EditorGUIUtility.RenderGameViewCamerasInternal(this.m_TargetTexture, targetDisplay, GUIClip.Unclip(this.viewInWindow), vector2, this.m_Gizmos);
                        state.ApplyAndForget();
                        GUIUtility.s_EditorScreenPointOffset = vector3;
                        GUI.BeginGroup(this.m_ZoomArea.drawRect);
                        GL.sRGBWrite = this.m_CurrentColorSpace == ColorSpace.Linear;
                        GUI.DrawTexture(this.deviceFlippedTargetInView, this.m_TargetTexture, ScaleMode.StretchToFill, false);
                        GL.sRGBWrite = false;
                        GUI.EndGroup();
                    }
                    break;
                }
                default:
                {
                    if (WindowLayout.s_MaximizeKey.activated && (!EditorApplication.isPlaying || EditorApplication.isPaused))
                    {
                        return;
                    }
                    bool flag2 = this.viewInWindow.Contains(Event.current.mousePosition);
                    if ((Event.current.rawType == EventType.MouseDown) && !flag2)
                    {
                        return;
                    }
                    Event.current.mousePosition = vector2;
                    Event.current.displayIndex = this.m_TargetDisplay;
                    EditorGUIUtility.QueueGameViewInputEvent(Event.current);
                    bool flag3 = true;
                    if ((Event.current.rawType == EventType.MouseUp) && !flag2)
                    {
                        flag3 = false;
                    }
                    switch (type)
                    {
                        case EventType.ExecuteCommand:
                        case EventType.ValidateCommand:
                            flag3 = false;
                            break;
                    }
                    if (flag3)
                    {
                        Event.current.Use();
                    }
                    else
                    {
                        Event.current.mousePosition = mousePosition;
                    }
                    break;
                }
            }
            this.m_ZoomArea.EndViewGUI();
            if ((type2 == EventType.ScrollWheel) && (Event.current.type == EventType.Used))
            {
                EditorApplication.update = (EditorApplication.CallbackFunction) Delegate.Remove(EditorApplication.update, new EditorApplication.CallbackFunction(this.SnapZoomDelayed));
                EditorApplication.update = (EditorApplication.CallbackFunction) Delegate.Combine(EditorApplication.update, new EditorApplication.CallbackFunction(this.SnapZoomDelayed));
                s_LastScrollTime = EditorApplication.timeSinceStartup;
            }
            this.EnforceZoomAreaConstraints();
            if (this.m_TargetTexture != null)
            {
                if (this.m_ZoomArea.scale.y < 1f)
                {
                    this.m_TargetTexture.filterMode = FilterMode.Bilinear;
                }
                else
                {
                    this.m_TargetTexture.filterMode = FilterMode.Point;
                }
            }
            if (this.m_NoCameraWarning && !EditorGUIUtility.IsDisplayReferencedByCameras(this.m_TargetDisplay))
            {
                GUI.Label(this.warningPosition, GUIContent.none, EditorStyles.notificationBackground);
                string str = !this.ShouldShowMultiDisplayOption() ? string.Empty : DisplayUtility.GetDisplayNames()[this.m_TargetDisplay].text;
                string t = string.Format("{0}\nNo cameras rendering", str);
                EditorGUI.DoDropShadowLabel(this.warningPosition, EditorGUIUtility.TempContent(t), EditorStyles.notificationText, 0.3f);
            }
            if (this.m_Stats)
            {
                GameViewGUI.GameViewStatsGUI();
            }
        }