示例#1
0
        private void AllRootCanvases()
        {
            if (PlayerSettings.virtualRealitySupported && (m_RenderMode.enumValueIndex == (int)RenderMode.ScreenSpaceOverlay))
            {
                EditorGUILayout.HelpBox("Using a render mode of ScreenSpaceOverlay while VR is enabled will cause the Canvas to continue to incur a rendering cost, even though the Canvas will not be visible in VR.", MessageType.Warning);
            }

            EditorGUILayout.PropertyField(m_RenderMode);

            m_OverlayMode.target = m_RenderMode.intValue == 0;
            m_CameraMode.target  = m_RenderMode.intValue == 1;
            m_WorldMode.target   = m_RenderMode.intValue == 2;

            EditorGUI.indentLevel++;
            if (EditorGUILayout.BeginFadeGroup(m_OverlayMode.faded))
            {
                EditorGUILayout.PropertyField(m_PixelPerfect);
                EditorGUILayout.PropertyField(m_SortingOrder, Styles.sortingOrder);
                GUIContent[] displayNames = DisplayUtility.GetDisplayNames();
                EditorGUILayout.IntPopup(m_TargetDisplay, displayNames, DisplayUtility.GetDisplayIndices(), Styles.targetDisplay);
            }
            EditorGUILayout.EndFadeGroup();

            if (EditorGUILayout.BeginFadeGroup(m_CameraMode.faded))
            {
                EditorGUILayout.PropertyField(m_PixelPerfect);
                EditorGUILayout.PropertyField(m_Camera, Styles.renderCamera);

                if (m_Camera.objectReferenceValue != null)
                {
                    EditorGUILayout.PropertyField(m_PlaneDistance);
                }

                EditorGUILayout.Space();

                if (m_Camera.objectReferenceValue != null)
                {
                    EditorGUILayout.SortingLayerField(Styles.m_SortingLayerStyle, m_SortingLayerID, EditorStyles.popup, EditorStyles.label);
                }
                EditorGUILayout.PropertyField(m_SortingOrder, Styles.m_SortingOrderStyle);

                if (m_Camera.objectReferenceValue == null)
                {
                    EditorGUILayout.HelpBox("Screen Space - A canvas with no specified camera acts like a Overlay Canvas." +
                                            " Please assign a camera to it in the 'Render Camera' field.", MessageType.Warning);
                }
            }
            EditorGUILayout.EndFadeGroup();

            if (EditorGUILayout.BeginFadeGroup(m_WorldMode.faded))
            {
                EditorGUILayout.PropertyField(m_Camera, Styles.eventCamera);
                EditorGUILayout.Space();
                EditorGUILayout.SortingLayerField(Styles.m_SortingLayerStyle, m_SortingLayerID, EditorStyles.popup);
                EditorGUILayout.PropertyField(m_SortingOrder, Styles.m_SortingOrderStyle);
            }
            EditorGUILayout.EndFadeGroup();
            EditorGUI.indentLevel--;
        }
示例#2
0
        private void DoToolbarGUI()
        {
            ScriptableSingleton <GameViewSizes> .instance.RefreshStandaloneAndWebplayerDefaultSizes();

            if (ScriptableSingleton <GameViewSizes> .instance.GetChangeID() != this.m_SizeChangeID)
            {
                this.EnsureSelectedSizeAreValid();
                this.m_SizeChangeID = ScriptableSingleton <GameViewSizes> .instance.GetChangeID();
            }
            GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
            if (this.ShouldShowMultiDisplayOption())
            {
                GUILayoutOption[] optionArray1 = new GUILayoutOption[] { GUILayout.Width(80f) };
                int num = EditorGUILayout.Popup(this.m_TargetDisplay, DisplayUtility.GetDisplayNames(), EditorStyles.toolbarPopup, optionArray1);
                EditorGUILayout.Space();
                if (num != this.m_TargetDisplay)
                {
                    this.m_TargetDisplay = num;
                    this.GameViewAspectWasChanged();
                }
            }
            GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(160f) };
            EditorGUILayout.GameViewSizePopup(currentSizeGroupType, this.selectedSizeIndex, new Action <int, object>(this.SelectionCallback), EditorStyles.toolbarDropDown, options);
            if (FrameDebuggerUtility.IsLocalEnabled())
            {
                GUILayout.FlexibleSpace();
                Color color = GUI.color;
                GUI.color *= AnimationMode.animatedPropertyColor;
                GUILayout.Label("Frame Debugger on", EditorStyles.miniLabel, new GUILayoutOption[0]);
                GUI.color = color;
                if (Event.current.type == EventType.Repaint)
                {
                    FrameDebuggerWindow.RepaintAll();
                }
            }
            GUILayout.FlexibleSpace();
            if (RenderDoc.IsLoaded())
            {
                EditorGUI.BeginDisabledGroup(!RenderDoc.IsSupported());
                if (GUILayout.Button(this.renderdocContent, EditorStyles.toolbarButton, new GUILayoutOption[0]))
                {
                    base.m_Parent.CaptureRenderDoc();
                    GUIUtility.ExitGUI();
                }
                EditorGUI.EndDisabledGroup();
            }
            this.m_MaximizeOnPlay         = GUILayout.Toggle(this.m_MaximizeOnPlay, "Maximize on Play", EditorStyles.toolbarButton, new GUILayoutOption[0]);
            EditorUtility.audioMasterMute = GUILayout.Toggle(EditorUtility.audioMasterMute, "Mute audio", EditorStyles.toolbarButton, new GUILayoutOption[0]);
            this.m_Stats = GUILayout.Toggle(this.m_Stats, "Stats", EditorStyles.toolbarButton, new GUILayoutOption[0]);
            Rect position = GUILayoutUtility.GetRect(this.gizmosContent, s_GizmoButtonStyle);
            Rect rect2    = new Rect(position.xMax - s_GizmoButtonStyle.border.right, position.y, (float)s_GizmoButtonStyle.border.right, position.height);

            if (EditorGUI.ButtonMouseDown(rect2, GUIContent.none, FocusType.Passive, GUIStyle.none) && AnnotationWindow.ShowAtPosition(GUILayoutUtility.topLevel.GetLast(), true))
            {
                GUIUtility.ExitGUI();
            }
            this.m_Gizmos = GUI.Toggle(position, this.m_Gizmos, this.gizmosContent, s_GizmoButtonStyle);
            GUILayout.EndHorizontal();
        }
示例#3
0
 public void DrawMultiDisplay()
 {
     if (ModuleManager.ShouldShowMultiDisplayOption())
     {
         int prevDisplay = targetDisplay.intValue;
         EditorGUILayout.IntPopup(targetDisplay, DisplayUtility.GetDisplayNames(), DisplayUtility.GetDisplayIndices(), EditorGUIUtility.TempContent("Target Display"));
         if (prevDisplay != targetDisplay.intValue)
         {
             GameView.RepaintAll();
         }
     }
 }
示例#4
0
 public void DrawMultiDisplay()
 {
     if (ModuleManager.ShouldShowMultiDisplayOption())
     {
         int intValue = this.targetDisplay.intValue;
         EditorGUILayout.Space();
         EditorGUILayout.IntPopup(this.targetDisplay, DisplayUtility.GetDisplayNames(), DisplayUtility.GetDisplayIndices(), EditorGUIUtility.TempContent("Target Display"), new GUILayoutOption[0]);
         if (intValue != this.targetDisplay.intValue)
         {
             GameView.RepaintAll();
         }
     }
 }
        private void AllRootCanvases()
        {
            EditorGUILayout.PropertyField(m_RenderMode);

            m_OverlayMode.target = m_RenderMode.intValue == 0;
            m_CameraMode.target = m_RenderMode.intValue == 1;
            m_WorldMode.target = m_RenderMode.intValue == 2;

            EditorGUI.indentLevel++;
            if (EditorGUILayout.BeginFadeGroup(m_OverlayMode.faded))
            {
                EditorGUILayout.PropertyField(m_PixelPerfect);
                EditorGUILayout.PropertyField(m_SortingOrder, Styles.sortingOrder);
                GUIContent[] displayNames = DisplayUtility.GetDisplayNames();
                EditorGUILayout.IntPopup(m_TargetDisplay, displayNames, DisplayUtility.GetDisplayIndices(), Styles.targetDisplay);
            }
            EditorGUILayout.EndFadeGroup();

            if (EditorGUILayout.BeginFadeGroup(m_CameraMode.faded))
            {
                EditorGUILayout.PropertyField(m_PixelPerfect);
                EditorGUILayout.PropertyField(m_Camera, Styles.renderCamera);

                if (m_Camera.objectReferenceValue != null)
                    EditorGUILayout.PropertyField(m_PlaneDistance);

                EditorGUILayout.Space();

                if (m_Camera.objectReferenceValue != null)
                    EditorGUILayout.SortingLayerField(Styles.m_SortingLayerStyle, m_SortingLayerID, EditorStyles.popup, EditorStyles.label);
                EditorGUILayout.PropertyField(m_SortingOrder, Styles.m_SortingOrderStyle);

                if (m_Camera.objectReferenceValue == null)
                    EditorGUILayout.HelpBox("Screen Space - A canvas with no specified camera acts like a Overlay Canvas." +
                        " Please assign a camera to it in the 'Render Camera' field.", MessageType.Warning);
            }
            EditorGUILayout.EndFadeGroup();

            if (EditorGUILayout.BeginFadeGroup(m_WorldMode.faded))
            {
                EditorGUILayout.PropertyField(m_Camera, Styles.eventCamera);
                EditorGUILayout.Space();
                EditorGUILayout.SortingLayerField(Styles.m_SortingLayerStyle, m_SortingLayerID, EditorStyles.popup);
                EditorGUILayout.PropertyField(m_SortingOrder, Styles.m_SortingOrderStyle);
            }
            EditorGUILayout.EndFadeGroup();
            EditorGUI.indentLevel--;
        }
示例#6
0
        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)
            {
                this.AllowCursorLockAndHide(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 mousePosition2 = this.WindowToGameMousePosition(mousePosition);

            GUI.color = Color.white;
            EventType type2 = Event.current.type;

            this.m_ZoomArea.BeginViewGUI();
            if (type == EventType.Repaint)
            {
                GUI.Box(this.m_ZoomArea.drawRect, GUIContent.none, GameView.Styles.gameViewBackgroundStyle);
                Vector2 s_EditorScreenPointOffset = GUIUtility.s_EditorScreenPointOffset;
                GUIUtility.s_EditorScreenPointOffset = Vector2.zero;
                SavedGUIState savedGUIState = SavedGUIState.Create();
                this.ConfigureTargetTexture((int)this.targetSize.x, (int)this.targetSize.y);
                if (this.m_ClearInEditMode && !EditorApplication.isPlaying)
                {
                    this.ClearTargetTexture();
                }
                int targetDisplay = 0;
                if (ModuleManager.ShouldShowMultiDisplayOption())
                {
                    targetDisplay = this.m_TargetDisplay;
                }
                if (this.m_TargetTexture.IsCreated())
                {
                    EditorGUIUtility.RenderGameViewCamerasInternal(this.m_TargetTexture, targetDisplay, GUIClip.Unclip(this.viewInWindow), mousePosition2, this.m_Gizmos);
                    savedGUIState.ApplyAndForget();
                    GUIUtility.s_EditorScreenPointOffset = s_EditorScreenPointOffset;
                    GUI.BeginGroup(this.m_ZoomArea.drawRect);
                    Graphics.DrawTexture(this.deviceFlippedTargetInView, this.m_TargetTexture, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, GUI.color, GUI.blitMaterial);
                    GUI.EndGroup();
                }
            }
            else if (type != EventType.Layout && type != EventType.Used)
            {
                if (WindowLayout.s_MaximizeKey.activated)
                {
                    if (!EditorApplication.isPlaying || EditorApplication.isPaused)
                    {
                        return;
                    }
                }
                bool flag2 = this.viewInWindow.Contains(Event.current.mousePosition);
                if (Event.current.rawType == EventType.MouseDown && !flag2)
                {
                    return;
                }
                int displayIndex = Event.current.displayIndex;
                Event.current.mousePosition = mousePosition2;
                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;
                }
                Event.current.displayIndex = displayIndex;
            }
            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));
                GameView.s_LastScrollTime = EditorApplication.timeSinceStartup;
            }
            this.EnforceZoomAreaConstraints();
            if (this.m_TargetTexture)
            {
                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 arg = (!ModuleManager.ShouldShowMultiDisplayOption()) ? string.Empty : DisplayUtility.GetDisplayNames()[this.m_TargetDisplay].text;
                string t   = string.Format("{0}\nNo cameras rendering", arg);
                EditorGUI.DoDropShadowLabel(this.warningPosition, EditorGUIUtility.TempContent(t), EditorStyles.notificationText, 0.3f);
            }
            if (this.m_Stats)
            {
                GameViewGUI.GameViewStatsGUI();
            }
        }
示例#7
0
        private void DoToolbarGUI()
        {
            ScriptableSingleton <GameViewSizes> .instance.RefreshStandaloneAndRemoteDefaultSizes();

            GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
            if (ModuleManager.ShouldShowMultiDisplayOption())
            {
                int num = EditorGUILayout.Popup(this.m_TargetDisplay, DisplayUtility.GetDisplayNames(), EditorStyles.toolbarPopup, new GUILayoutOption[]
                {
                    GUILayout.Width(80f)
                });
                EditorGUILayout.Space();
                if (num != this.m_TargetDisplay)
                {
                    this.m_TargetDisplay = num;
                    this.UpdateZoomAreaAndParent();
                }
            }
            EditorGUILayout.GameViewSizePopup(GameView.currentSizeGroupType, this.selectedSizeIndex, this, EditorStyles.toolbarPopup, new GUILayoutOption[]
            {
                GUILayout.Width(160f)
            });
            this.DoZoomSlider();
            if (FrameDebuggerUtility.IsLocalEnabled())
            {
                GUILayout.FlexibleSpace();
                Color color = GUI.color;
                GUI.color *= AnimationMode.recordedPropertyColor;
                GUILayout.Label(GameView.Styles.frameDebuggerOnContent, EditorStyles.miniLabel, new GUILayoutOption[0]);
                GUI.color = color;
                if (Event.current.type == EventType.Repaint)
                {
                    FrameDebuggerWindow.RepaintAll();
                }
            }
            GUILayout.FlexibleSpace();
            if (RenderDoc.IsLoaded())
            {
                using (new EditorGUI.DisabledScope(!RenderDoc.IsSupported()))
                {
                    if (GUILayout.Button(GameView.Styles.renderdocContent, EditorStyles.toolbarButton, new GUILayoutOption[0]))
                    {
                        this.m_Parent.CaptureRenderDoc();
                        GUIUtility.ExitGUI();
                    }
                }
            }
            this.m_MaximizeOnPlay         = GUILayout.Toggle(this.m_MaximizeOnPlay, GameView.Styles.maximizeOnPlayContent, EditorStyles.toolbarButton, new GUILayoutOption[0]);
            EditorUtility.audioMasterMute = GUILayout.Toggle(EditorUtility.audioMasterMute, GameView.Styles.muteContent, EditorStyles.toolbarButton, new GUILayoutOption[0]);
            this.m_Stats = GUILayout.Toggle(this.m_Stats, GameView.Styles.statsContent, EditorStyles.toolbarButton, new GUILayoutOption[0]);
            Rect rect     = GUILayoutUtility.GetRect(GameView.Styles.gizmosContent, GameView.Styles.gizmoButtonStyle);
            Rect position = new Rect(rect.xMax - (float)GameView.Styles.gizmoButtonStyle.border.right, rect.y, (float)GameView.Styles.gizmoButtonStyle.border.right, rect.height);

            if (EditorGUI.DropdownButton(position, GUIContent.none, FocusType.Passive, GUIStyle.none))
            {
                Rect last = GUILayoutUtility.topLevel.GetLast();
                if (AnnotationWindow.ShowAtPosition(last, true))
                {
                    GUIUtility.ExitGUI();
                }
            }
            this.m_Gizmos = GUI.Toggle(rect, this.m_Gizmos, GameView.Styles.gizmosContent, GameView.Styles.gizmoButtonStyle);
            GUILayout.EndHorizontal();
        }
示例#8
0
        private void DoToolbarGUI()
        {
            GameViewSizes.instance.RefreshStandaloneAndRemoteDefaultSizes();

            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            {
                if (ModuleManager.ShouldShowMultiDisplayOption())
                {
                    int display = EditorGUILayout.Popup(m_TargetDisplay, DisplayUtility.GetDisplayNames(), EditorStyles.toolbarPopup, GUILayout.Width(80));
                    EditorGUILayout.Space();
                    if (display != m_TargetDisplay)
                    {
                        m_TargetDisplay = display;
                        UpdateZoomAreaAndParent();
                    }
                }
                EditorGUILayout.GameViewSizePopup(currentSizeGroupType, selectedSizeIndex, this, EditorStyles.toolbarPopup, GUILayout.Width(160f));

                DoZoomSlider();

                if (FrameDebuggerUtility.IsLocalEnabled())
                {
                    GUILayout.FlexibleSpace();
                    Color oldCol = GUI.color;
                    // This has nothing to do with animation recording.  Can we replace this color with something else?
                    GUI.color *= AnimationMode.recordedPropertyColor;
                    GUILayout.Label(Styles.frameDebuggerOnContent, EditorStyles.miniLabel);
                    GUI.color = oldCol;
                    // Make frame debugger windows repaint after each time game view repaints.
                    // We want them to always display the latest & greatest game view
                    // rendering state.
                    if (Event.current.type == EventType.Repaint)
                    {
                        FrameDebuggerWindow.RepaintAll();
                    }
                }

                GUILayout.FlexibleSpace();

                if (RenderDoc.IsLoaded())
                {
                    using (new EditorGUI.DisabledScope(!RenderDoc.IsSupported()))
                    {
                        if (GUILayout.Button(Styles.renderdocContent, EditorStyles.toolbarButton))
                        {
                            m_Parent.CaptureRenderDoc();
                            GUIUtility.ExitGUI();
                        }
                    }
                }

                m_MaximizeOnPlay = GUILayout.Toggle(m_MaximizeOnPlay, Styles.maximizeOnPlayContent, EditorStyles.toolbarButton);
                EditorUtility.audioMasterMute = GUILayout.Toggle(EditorUtility.audioMasterMute, Styles.muteContent, EditorStyles.toolbarButton);
                m_Stats = GUILayout.Toggle(m_Stats, Styles.statsContent, EditorStyles.toolbarButton);

                Rect r         = GUILayoutUtility.GetRect(Styles.gizmosContent, Styles.gizmoButtonStyle);
                Rect rightRect = new Rect(r.xMax - Styles.gizmoButtonStyle.border.right, r.y, Styles.gizmoButtonStyle.border.right, r.height);
                if (EditorGUI.DropdownButton(rightRect, GUIContent.none, FocusType.Passive, GUIStyle.none))
                {
                    Rect rect = GUILayoutUtility.topLevel.GetLast();
                    if (AnnotationWindow.ShowAtPosition(rect, true))
                    {
                        GUIUtility.ExitGUI();
                    }
                }
                m_Gizmos = GUI.Toggle(r, m_Gizmos, Styles.gizmosContent, Styles.gizmoButtonStyle);
            }
            GUILayout.EndHorizontal();
        }
示例#9
0
 public override void OnInspectorGUI()
 {
     base.serializedObject.Update();
     if (this.m_AllRoot)
     {
         EditorGUILayout.PropertyField(this.m_RenderMode, new GUILayoutOption[0]);
         this.m_OverlayMode.target = this.m_RenderMode.intValue == 0;
         this.m_CameraMode.target  = this.m_RenderMode.intValue == 1;
         this.m_WorldMode.target   = this.m_RenderMode.intValue == 2;
         EditorGUI.indentLevel++;
         if (EditorGUILayout.BeginFadeGroup(this.m_OverlayMode.faded))
         {
             EditorGUILayout.PropertyField(this.m_PixelPerfect, new GUILayoutOption[0]);
             EditorGUILayout.PropertyField(this.m_SortingOrder, Styles.sortingOrder, new GUILayoutOption[0]);
             GUIContent[] displayNames = DisplayUtility.GetDisplayNames();
             EditorGUILayout.IntPopup(this.m_TargetDisplay, displayNames, DisplayUtility.GetDisplayIndices(), Styles.targetDisplay, new GUILayoutOption[0]);
         }
         EditorGUILayout.EndFadeGroup();
         if (EditorGUILayout.BeginFadeGroup(this.m_CameraMode.faded))
         {
             EditorGUILayout.PropertyField(this.m_PixelPerfect, new GUILayoutOption[0]);
             EditorGUILayout.PropertyField(this.m_Camera, Styles.renderCamera, new GUILayoutOption[0]);
             if (this.m_Camera.objectReferenceValue != null)
             {
                 EditorGUILayout.PropertyField(this.m_PlaneDistance, new GUILayoutOption[0]);
             }
             EditorGUILayout.Space();
             if (this.m_Camera.objectReferenceValue != null)
             {
                 EditorGUILayout.SortingLayerField(Styles.m_SortingLayerStyle, this.m_SortingLayerID, EditorStyles.popup, EditorStyles.label);
             }
             EditorGUILayout.PropertyField(this.m_SortingOrder, Styles.m_SortingOrderStyle, new GUILayoutOption[0]);
             if (this.m_Camera.objectReferenceValue == null)
             {
                 EditorGUILayout.HelpBox("Screen Space - A canvas with no specified camera acts like a Overlay Canvas. Please assign a camera to it in the 'Render Camera' field.", MessageType.Warning);
             }
         }
         EditorGUILayout.EndFadeGroup();
         if (EditorGUILayout.BeginFadeGroup(this.m_WorldMode.faded))
         {
             EditorGUILayout.PropertyField(this.m_Camera, Styles.eventCamera, new GUILayoutOption[0]);
             EditorGUILayout.Space();
             EditorGUILayout.SortingLayerField(Styles.m_SortingLayerStyle, this.m_SortingLayerID, EditorStyles.popup);
             EditorGUILayout.PropertyField(this.m_SortingOrder, Styles.m_SortingOrderStyle, new GUILayoutOption[0]);
         }
         EditorGUILayout.EndFadeGroup();
         EditorGUI.indentLevel--;
     }
     else if (this.m_AllNested)
     {
         EditorGUI.BeginChangeCheck();
         this.pixelPerfect = (PixelPerfect)EditorGUILayout.EnumPopup("Pixel Perfect", this.pixelPerfect, new GUILayoutOption[0]);
         if (EditorGUI.EndChangeCheck())
         {
             if (this.pixelPerfect == PixelPerfect.Inherit)
             {
                 this.m_PixelPerfectOverride.boolValue = false;
             }
             else if (this.pixelPerfect == PixelPerfect.Off)
             {
                 this.m_PixelPerfectOverride.boolValue = true;
                 this.m_PixelPerfect.boolValue         = false;
             }
             else
             {
                 this.m_PixelPerfectOverride.boolValue = true;
                 this.m_PixelPerfect.boolValue         = true;
             }
         }
         EditorGUI.BeginChangeCheck();
         EditorGUILayout.PropertyField(this.m_OverrideSorting, new GUILayoutOption[0]);
         if (EditorGUI.EndChangeCheck())
         {
             ((Canvas)base.serializedObject.targetObject).overrideSorting = this.m_OverrideSorting.boolValue;
             this.m_SortingOverride.target = this.m_OverrideSorting.boolValue;
         }
         if (EditorGUILayout.BeginFadeGroup(this.m_SortingOverride.faded))
         {
             GUIContent label = null;
             if (this.m_AllOverlay)
             {
                 label = Styles.sortingOrder;
             }
             else if (this.m_NoneOverlay)
             {
                 label = Styles.m_SortingOrderStyle;
                 EditorGUILayout.SortingLayerField(Styles.m_SortingLayerStyle, this.m_SortingLayerID, EditorStyles.popup);
             }
             if (label != null)
             {
                 EditorGUI.BeginChangeCheck();
                 EditorGUILayout.PropertyField(this.m_SortingOrder, label, new GUILayoutOption[0]);
                 if (EditorGUI.EndChangeCheck())
                 {
                     ((Canvas)base.serializedObject.targetObject).sortingOrder = this.m_SortingOrder.intValue;
                 }
             }
         }
         EditorGUILayout.EndFadeGroup();
     }
     else
     {
         GUILayout.Label(Styles.s_RootAndNestedMessage, EditorStyles.helpBox, new GUILayoutOption[0]);
     }
     base.serializedObject.ApplyModifiedProperties();
 }
示例#10
0
        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 = UnityEngine.FilterMode.Bilinear;
                }
                else
                {
                    this.m_TargetTexture.filterMode = UnityEngine.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   = $"{str}
No cameras rendering";
                EditorGUI.DoDropShadowLabel(this.warningPosition, EditorGUIUtility.TempContent(t), EditorStyles.notificationText, 0.3f);
            }
            if (this.m_Stats)
            {
                GameViewGUI.GameViewStatsGUI();
            }
        }
示例#11
0
        public override void OnInspectorGUI()
        {
            this.serializedObject.Update();
            Camera target = (Camera)this.target;

            this.m_ShowBGColorOptions.target  = !this.m_ClearFlags.hasMultipleDifferentValues && (target.clearFlags == CameraClearFlags.Color || target.clearFlags == CameraClearFlags.Skybox);
            this.m_ShowOrthoOptions.target    = !this.m_Orthographic.hasMultipleDifferentValues && target.orthographic;
            this.m_ShowTargetEyeOption.target = this.m_TargetEye.intValue != 3 || PlayerSettings.virtualRealitySupported || PlayerSettings.stereoscopic3D;
            EditorGUILayout.PropertyField(this.m_ClearFlags);
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowBGColorOptions.faded))
            {
                EditorGUILayout.PropertyField(this.m_BackgroundColor, new GUIContent("Background", "Camera clears the screen to this color before rendering."), new GUILayoutOption[0]);
            }
            EditorGUILayout.EndFadeGroup();
            EditorGUILayout.PropertyField(this.m_CullingMask);
            EditorGUILayout.Space();
            CameraEditor.ProjectionType projectionType1 = !this.m_Orthographic.boolValue ? CameraEditor.ProjectionType.Perspective : CameraEditor.ProjectionType.Orthographic;
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = this.m_Orthographic.hasMultipleDifferentValues;
            CameraEditor.ProjectionType projectionType2 = (CameraEditor.ProjectionType)EditorGUILayout.EnumPopup("Projection", (Enum)projectionType1, new GUILayoutOption[0]);
            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                this.m_Orthographic.boolValue = projectionType2 == CameraEditor.ProjectionType.Orthographic;
            }
            if (!this.m_Orthographic.hasMultipleDifferentValues)
            {
                if (EditorGUILayout.BeginFadeGroup(this.m_ShowOrthoOptions.faded))
                {
                    EditorGUILayout.PropertyField(this.m_OrthographicSize, new GUIContent("Size"), new GUILayoutOption[0]);
                }
                EditorGUILayout.EndFadeGroup();
                if (EditorGUILayout.BeginFadeGroup(1f - this.m_ShowOrthoOptions.faded))
                {
                    EditorGUILayout.Slider(this.m_FieldOfView, 1f, 179f, new GUIContent("Field of View"), new GUILayoutOption[0]);
                }
                EditorGUILayout.EndFadeGroup();
            }
            EditorGUILayout.PropertiesField(EditorGUI.s_ClipingPlanesLabel, this.m_NearAndFarClippingPlanes, EditorGUI.s_NearAndFarLabels, 35f);
            EditorGUILayout.PropertyField(this.m_NormalizedViewPortRect, this.m_ViewportLabel, new GUILayoutOption[0]);
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(this.m_Depth);
            EditorGUILayout.IntPopup(this.m_RenderingPath, CameraEditor.kCameraRenderPaths, CameraEditor.kCameraRenderPathValues, EditorGUIUtility.TempContent("Rendering Path"), new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_TargetTexture);
            EditorGUILayout.PropertyField(this.m_OcclusionCulling);
            EditorGUILayout.PropertyField(this.m_HDR);
            if (this.m_HDR.boolValue)
            {
                this.DisplayHDRWarnings();
            }
            if (PlayerSettings.stereoscopic3D)
            {
                EditorGUILayout.PropertyField(this.m_StereoSeparation);
                EditorGUILayout.PropertyField(this.m_StereoConvergence);
            }
            if (this.ShouldShowTargetDisplayProperty())
            {
                int intValue = this.m_TargetDisplay.intValue;
                EditorGUILayout.Space();
                EditorGUILayout.IntPopup(this.m_TargetDisplay, DisplayUtility.GetDisplayNames(), DisplayUtility.GetDisplayIndices(), EditorGUIUtility.TempContent("Target Display"), new GUILayoutOption[0]);
                if (intValue != this.m_TargetDisplay.intValue)
                {
                    GameView.RepaintAll();
                }
            }
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowTargetEyeOption.faded))
            {
                EditorGUILayout.IntPopup(this.m_TargetEye, CameraEditor.kTargetEyes, CameraEditor.kTargetEyeValues, EditorGUIUtility.TempContent("Target Eye"), new GUILayoutOption[0]);
            }
            EditorGUILayout.EndFadeGroup();
            this.DepthTextureModeGUI();
            this.CommandBufferGUI();
            this.serializedObject.ApplyModifiedProperties();
        }
示例#12
0
        public override void OnInspectorGUI()
        {
            base.serializedObject.Update();
            Camera camera = (Camera)base.target;

            this.m_ShowBGColorOptions.target  = (!this.m_ClearFlags.hasMultipleDifferentValues && (camera.clearFlags == CameraClearFlags.Color || camera.clearFlags == CameraClearFlags.Skybox));
            this.m_ShowOrthoOptions.target    = (!this.m_Orthographic.hasMultipleDifferentValues && camera.orthographic);
            this.m_ShowTargetEyeOption.target = (this.m_TargetEye.intValue != 3 || PlayerSettings.virtualRealitySupported);
            EditorGUILayout.PropertyField(this.m_ClearFlags, new GUILayoutOption[0]);
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowBGColorOptions.faded))
            {
                EditorGUILayout.PropertyField(this.m_BackgroundColor, new GUIContent("Background", "Camera clears the screen to this color before rendering."), new GUILayoutOption[0]);
            }
            EditorGUILayout.EndFadeGroup();
            EditorGUILayout.PropertyField(this.m_CullingMask, new GUILayoutOption[0]);
            EditorGUILayout.Space();
            CameraEditor.ProjectionType projectionType = (!this.m_Orthographic.boolValue) ? CameraEditor.ProjectionType.Perspective : CameraEditor.ProjectionType.Orthographic;
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = this.m_Orthographic.hasMultipleDifferentValues;
            projectionType           = (CameraEditor.ProjectionType)EditorGUILayout.EnumPopup("Projection", projectionType, new GUILayoutOption[0]);
            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                this.m_Orthographic.boolValue = (projectionType == CameraEditor.ProjectionType.Orthographic);
            }
            if (!this.m_Orthographic.hasMultipleDifferentValues)
            {
                if (EditorGUILayout.BeginFadeGroup(this.m_ShowOrthoOptions.faded))
                {
                    EditorGUILayout.PropertyField(this.m_OrthographicSize, new GUIContent("Size"), new GUILayoutOption[0]);
                }
                EditorGUILayout.EndFadeGroup();
                if (EditorGUILayout.BeginFadeGroup(1f - this.m_ShowOrthoOptions.faded))
                {
                    EditorGUILayout.Slider(this.m_FieldOfView, 1f, 179f, new GUIContent("Field of View"), new GUILayoutOption[0]);
                }
                EditorGUILayout.EndFadeGroup();
            }
            EditorGUILayout.PropertiesField(EditorGUI.s_ClipingPlanesLabel, this.m_NearAndFarClippingPlanes, EditorGUI.s_NearAndFarLabels, 35f, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_NormalizedViewPortRect, this.m_ViewportLabel, new GUILayoutOption[0]);
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(this.m_Depth, new GUILayoutOption[0]);
            EditorGUILayout.IntPopup(this.m_RenderingPath, CameraEditor.kCameraRenderPaths, CameraEditor.kCameraRenderPathValues, EditorGUIUtility.TempContent("Rendering Path"), new GUILayoutOption[0]);
            if (this.m_ShowOrthoOptions.target && this.wantDeferredRendering)
            {
                EditorGUILayout.HelpBox("Deferred rendering does not work with Orthographic camera, will use Forward.", MessageType.Warning, true);
            }
            EditorGUILayout.PropertyField(this.m_TargetTexture, new GUILayoutOption[0]);
            if (!this.m_TargetTexture.hasMultipleDifferentValues)
            {
                RenderTexture renderTexture = this.m_TargetTexture.objectReferenceValue as RenderTexture;
                if (renderTexture && renderTexture.antiAliasing > 1 && this.wantDeferredRendering)
                {
                    EditorGUILayout.HelpBox("Manual MSAA target set with deferred rendering. This will lead to undefined behavior.", MessageType.Warning, true);
                }
            }
            EditorGUILayout.PropertyField(this.m_OcclusionCulling, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_HDR, EditorGUIUtility.TempContent("Allow HDR"), new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_AllowMSAA, new GUILayoutOption[0]);
            this.DisplayCameraWarnings();
            if (PlayerSettings.virtualRealitySupported)
            {
                EditorGUILayout.PropertyField(this.m_StereoSeparation, new GUILayoutOption[0]);
                EditorGUILayout.PropertyField(this.m_StereoConvergence, new GUILayoutOption[0]);
            }
            if (this.ShouldShowTargetDisplayProperty())
            {
                int intValue = this.m_TargetDisplay.intValue;
                EditorGUILayout.Space();
                EditorGUILayout.IntPopup(this.m_TargetDisplay, DisplayUtility.GetDisplayNames(), DisplayUtility.GetDisplayIndices(), EditorGUIUtility.TempContent("Target Display"), new GUILayoutOption[0]);
                if (intValue != this.m_TargetDisplay.intValue)
                {
                    GameView.RepaintAll();
                }
            }
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowTargetEyeOption.faded))
            {
                EditorGUILayout.IntPopup(this.m_TargetEye, CameraEditor.kTargetEyes, CameraEditor.kTargetEyeValues, EditorGUIUtility.TempContent("Target Eye"), new GUILayoutOption[0]);
            }
            EditorGUILayout.EndFadeGroup();
            this.DepthTextureModeGUI();
            this.CommandBufferGUI();
            base.serializedObject.ApplyModifiedProperties();
        }
        internal static GUIContent[] GetDisplayNamesForBuildTarget(BuildTarget buildTarget)
        {
            var platformDisplayNames = Modules.ModuleManager.GetDisplayNames(buildTarget.ToString());

            return(platformDisplayNames ?? DisplayUtility.GetGenericDisplayNames());
        }
示例#14
0
 public override void OnInspectorGUI()
 {
     this.serializedObject.Update();
     if (this.m_AllRoot)
     {
         EditorGUILayout.PropertyField(this.m_RenderMode);
         this.m_OverlayMode.target = this.m_RenderMode.intValue == 0;
         this.m_CameraMode.target  = this.m_RenderMode.intValue == 1;
         this.m_WorldMode.target   = this.m_RenderMode.intValue == 2;
         ++EditorGUI.indentLevel;
         if (EditorGUILayout.BeginFadeGroup(this.m_OverlayMode.faded))
         {
             EditorGUILayout.PropertyField(this.m_PixelPerfect);
             EditorGUILayout.PropertyField(this.m_SortingOrder, this.sortingOrder, new GUILayoutOption[0]);
             EditorGUILayout.IntPopup(this.m_TargetDisplay, DisplayUtility.GetDisplayNames(), DisplayUtility.GetDisplayIndices(), this.targetDisplay, new GUILayoutOption[0]);
         }
         EditorGUILayout.EndFadeGroup();
         if (EditorGUILayout.BeginFadeGroup(this.m_CameraMode.faded))
         {
             EditorGUILayout.PropertyField(this.m_PixelPerfect);
             EditorGUILayout.PropertyField(this.m_Camera, this.renderCamera, new GUILayoutOption[0]);
             if (this.m_Camera.objectReferenceValue != (UnityEngine.Object)null)
             {
                 EditorGUILayout.PropertyField(this.m_PlaneDistance);
             }
             EditorGUILayout.Space();
             if (this.m_Camera.objectReferenceValue != (UnityEngine.Object)null)
             {
                 EditorGUILayout.SortingLayerField(this.m_SortingLayerStyle, this.m_SortingLayerID, EditorStyles.popup, EditorStyles.label);
             }
             EditorGUILayout.PropertyField(this.m_SortingOrder, this.m_SortingOrderStyle, new GUILayoutOption[0]);
             if (this.m_Camera.objectReferenceValue == (UnityEngine.Object)null)
             {
                 EditorGUILayout.HelpBox("Screen Space - Camera with no specified camera acts like a Overlay Canvas", MessageType.Warning);
             }
         }
         EditorGUILayout.EndFadeGroup();
         if (EditorGUILayout.BeginFadeGroup(this.m_WorldMode.faded))
         {
             EditorGUILayout.PropertyField(this.m_Camera, this.eventCamera, new GUILayoutOption[0]);
             EditorGUILayout.Space();
             EditorGUILayout.SortingLayerField(this.m_SortingLayerStyle, this.m_SortingLayerID, EditorStyles.popup);
             EditorGUILayout.PropertyField(this.m_SortingOrder, this.m_SortingOrderStyle, new GUILayoutOption[0]);
         }
         EditorGUILayout.EndFadeGroup();
         --EditorGUI.indentLevel;
     }
     else if (this.m_AllNested)
     {
         EditorGUI.BeginChangeCheck();
         this.pixelPerfect = (CanvasEditor.PixelPerfect)EditorGUILayout.EnumPopup("Pixel Perfect", (Enum)this.pixelPerfect, new GUILayoutOption[0]);
         if (EditorGUI.EndChangeCheck())
         {
             if (this.pixelPerfect == CanvasEditor.PixelPerfect.Inherit)
             {
                 this.m_PixelPerfectOverride.boolValue = false;
             }
             else if (this.pixelPerfect == CanvasEditor.PixelPerfect.Off)
             {
                 this.m_PixelPerfectOverride.boolValue = true;
                 this.m_PixelPerfect.boolValue         = false;
             }
             else
             {
                 this.m_PixelPerfectOverride.boolValue = true;
                 this.m_PixelPerfect.boolValue         = true;
             }
         }
         EditorGUILayout.PropertyField(this.m_OverrideSorting);
         this.m_SortingOverride.target = this.m_OverrideSorting.boolValue;
         if (EditorGUILayout.BeginFadeGroup(this.m_SortingOverride.faded))
         {
             if (this.m_AllOverlay)
             {
                 EditorGUILayout.PropertyField(this.m_SortingOrder, this.sortingOrder, new GUILayoutOption[0]);
             }
             else if (this.m_NoneOverlay)
             {
                 EditorGUILayout.SortingLayerField(this.m_SortingLayerStyle, this.m_SortingLayerID, EditorStyles.popup);
                 EditorGUILayout.PropertyField(this.m_SortingOrder, this.m_SortingOrderStyle, new GUILayoutOption[0]);
             }
         }
         EditorGUILayout.EndFadeGroup();
     }
     else
     {
         GUILayout.Label(CanvasEditor.s_RootAndNestedMessage, EditorStyles.helpBox, new GUILayoutOption[0]);
     }
     this.serializedObject.ApplyModifiedProperties();
 }
示例#15
0
        private void DoToolbarGUI()
        {
            GameViewSizes.instance.RefreshStandaloneAndRemoteDefaultSizes();

            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            {
                var availableTypes = GetAvailableWindowTypes();
                if (availableTypes.Count > 1)
                {
                    var typeNames = availableTypes.Values.ToList();
                    var types     = availableTypes.Keys.ToList();
                    int viewIndex = EditorGUILayout.Popup(typeNames.IndexOf(titleContent.text), typeNames.ToArray(),
                                                          EditorStyles.toolbarPopup,
                                                          GUILayout.Width(90));
                    EditorGUILayout.Space();
                    if (types[viewIndex] != typeof(GameView))
                    {
                        SwapMainWindow(types[viewIndex]);
                    }
                }

                if (ModuleManager.ShouldShowMultiDisplayOption())
                {
                    int display = EditorGUILayout.Popup(targetDisplay, DisplayUtility.GetDisplayNames(), EditorStyles.toolbarPopupLeft, GUILayout.Width(80));
                    if (display != targetDisplay)
                    {
                        targetDisplay = display;
                        UpdateZoomAreaAndParent();
                    }
                }
                EditorGUILayout.GameViewSizePopup(currentSizeGroupType, selectedSizeIndex, this, EditorStyles.toolbarPopup, GUILayout.Width(160f));

                DoZoomSlider();
                // If the previous platform and current does not match, update the scale
                if ((int)currentSizeGroupType != prevSizeGroupType)
                {
                    UpdateZoomAreaAndParent();
                    // Update the platform to the recent one
                    prevSizeGroupType = (int)currentSizeGroupType;
                }

                if (FrameDebuggerUtility.IsLocalEnabled())
                {
                    GUILayout.FlexibleSpace();
                    Color oldCol = GUI.color;
                    // This has nothing to do with animation recording.  Can we replace this color with something else?
                    GUI.color *= AnimationMode.recordedPropertyColor;
                    GUILayout.Label(Styles.frameDebuggerOnContent, EditorStyles.toolbarLabel);
                    GUI.color = oldCol;
                    // Make frame debugger windows repaint after each time game view repaints.
                    // We want them to always display the latest & greatest game view
                    // rendering state.
                    if (Event.current.type == EventType.Repaint)
                    {
                        FrameDebuggerWindow.RepaintAll();
                    }
                }

                GUILayout.FlexibleSpace();

                if (RenderDoc.IsLoaded())
                {
                    using (new EditorGUI.DisabledScope(!RenderDoc.IsSupported()))
                    {
                        if (GUILayout.Button(Styles.renderdocContent, EditorStyles.toolbarButton))
                        {
                            m_Parent.CaptureRenderDocScene();
                            GUIUtility.ExitGUI();
                        }
                    }
                }

                // Allow the user to select how the XR device will be rendered during "Play In Editor"
                if (PlayerSettings.virtualRealitySupported)
                {
                    int selectedRenderMode = EditorGUILayout.Popup(m_XRRenderMode, Styles.xrRenderingModes, EditorStyles.toolbarPopup, GUILayout.Width(80));
                    SetXRRenderMode(selectedRenderMode);
                }

                maximizeOnPlay = GUILayout.Toggle(maximizeOnPlay, Styles.maximizeOnPlayContent, EditorStyles.toolbarButton);

                EditorUtility.audioMasterMute = GUILayout.Toggle(EditorUtility.audioMasterMute, Styles.muteContent, EditorStyles.toolbarButton);

                m_Stats = GUILayout.Toggle(m_Stats, Styles.statsContent, EditorStyles.toolbarButton);

                if (EditorGUILayout.DropDownToggle(ref m_Gizmos, Styles.gizmosContent, EditorStyles.toolbarDropDownToggleRight))
                {
                    Rect rect = GUILayoutUtility.topLevel.GetLast();
                    if (AnnotationWindow.ShowAtPosition(rect, true))
                    {
                        GUIUtility.ExitGUI();
                    }
                }
            }
            GUILayout.EndHorizontal();
        }
示例#16
0
        private void OnGUI()
        {
            if (position.size * EditorGUIUtility.pixelsPerPoint != m_LastWindowPixelSize) // pixelsPerPoint only reliable in OnGUI()
            {
                UpdateZoomAreaAndParent();
            }

            if (showToolbar)
            {
                DoToolbarGUI();
            }

            // This isn't ideal. Custom Cursors set by editor extensions for other windows can leak into the game view.
            // To fix this we should probably stop using the global custom cursor (intended for runtime) for custom editor cursors.
            // This has been noted for Cursors tech debt.
            EditorGUIUtility.AddCursorRect(viewInWindow, MouseCursor.CustomCursor);

            EventType type = Event.current.type;

            // Gain mouse lock when clicking on game view content
            if (type == EventType.MouseDown && viewInWindow.Contains(Event.current.mousePosition))
            {
                AllowCursorLockAndHide(true);
            }
            // Lose mouse lock when pressing escape
            else if (type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
            {
                AllowCursorLockAndHide(false);
            }

            // We hide sliders when playing, and also when we are zoomed out beyond canvas edges
            var playing = EditorApplication.isPlaying && !EditorApplication.isPaused;
            var targetInContentCached = targetInContent;

            m_ZoomArea.hSlider          = !playing && m_ZoomArea.shownArea.width < targetInContentCached.width;
            m_ZoomArea.vSlider          = !playing && m_ZoomArea.shownArea.height < targetInContentCached.height;
            m_ZoomArea.enableMouseInput = !playing;
            ConfigureZoomArea();

            // We don't want controls inside the GameView (e.g. the toolbar) to have keyboard focus while playing.
            // The game should get the keyboard events.
            if (playing)
            {
                EditorGUIUtility.keyboardControl = 0;
            }

            GUI.color = Color.white; // Get rid of play mode tint

            var originalEventType = Event.current.type;

            m_ZoomArea.BeginViewGUI();

            // Window size might change on Layout event
            if (type == EventType.Layout)
            {
                targetSize = targetRenderSize;
            }

            // Setup game view dimensions, so that player loop can use it for input
            var gameViewTarget = GUIClip.UnclipToWindow(m_ZoomArea.drawRect);

            if (m_Parent)
            {
                var zoomedTarget = new Rect(targetInView.position + gameViewTarget.position, targetInView.size);
                SetParentGameViewDimensions(zoomedTarget, gameViewTarget, targetRenderSize);
            }

            var editorMousePosition = Event.current.mousePosition;
            var gameMousePosition   = (editorMousePosition + gameMouseOffset) * gameMouseScale;

            if (type == EventType.Repaint)
            {
                GUI.Box(m_ZoomArea.drawRect, GUIContent.none, Styles.gameViewBackgroundStyle);

                Vector2 oldOffset = GUIUtility.s_EditorScreenPointOffset;
                GUIUtility.s_EditorScreenPointOffset = Vector2.zero;
                SavedGUIState oldState = SavedGUIState.Create();


                var clearTexture = m_ClearInEditMode && !EditorApplication.isPlaying;

                var currentTargetDisplay = 0;
                if (ModuleManager.ShouldShowMultiDisplayOption())
                {
                    // Display Targets can have valid targets from 0 to 7.
                    System.Diagnostics.Debug.Assert(targetDisplay < 8, "Display Target is Out of Range");
                    currentTargetDisplay = targetDisplay;
                }

                targetDisplay = currentTargetDisplay;
                targetSize    = targetRenderSize;
                showGizmos    = m_Gizmos;
                clearColor    = kClearBlack;
                renderIMGUI   = true;

                if (!EditorApplication.isPlaying || (EditorApplication.isPlaying && Time.frameCount % OnDemandRendering.renderFrameInterval == 0))
                {
                    m_RenderTexture = RenderView(gameMousePosition, clearTexture);
                }

                if (m_TargetClamped)
                {
                    Debug.LogWarningFormat("GameView reduced to a reasonable size for this system ({0}x{1})", targetSize.x, targetSize.y);
                }
                EditorGUIUtility.SetupWindowSpaceAndVSyncInternal(GUIClip.Unclip(viewInWindow));

                if (m_RenderTexture != null && m_RenderTexture.IsCreated())
                {
                    oldState.ApplyAndForget();
                    GUIUtility.s_EditorScreenPointOffset = oldOffset;

                    GUI.BeginGroup(m_ZoomArea.drawRect);
                    // Actually draw the game view to the screen, without alpha blending
                    Rect drawRect = deviceFlippedTargetInView;
                    drawRect.x = Mathf.Round(drawRect.x);
                    drawRect.y = Mathf.Round(drawRect.y);
                    Graphics.DrawTexture(drawRect, m_RenderTexture, new Rect(0, 0, 1, 1), 0, 0, 0, 0, GUI.color, GUI.blitMaterial);
                    GUI.EndGroup();
                }
            }
            else if (type != EventType.Layout && type != EventType.Used)
            {
                if (Event.current.isKey && (!EditorApplication.isPlaying || EditorApplication.isPaused))
                {
                    return;
                }

                bool mousePosInGameViewRect = viewInWindow.Contains(Event.current.mousePosition);

                // MouseDown events outside game view rect are not send to scripts but MouseUp events are (see below)
                if (Event.current.rawType == EventType.MouseDown && !mousePosInGameViewRect)
                {
                    return;
                }

                var originalDisplayIndex = Event.current.displayIndex;

                // Transform events into local space, so the mouse position is correct
                // Then queue it up for playback during playerloop
                Event.current.mousePosition = gameMousePosition;
                Event.current.displayIndex  = targetDisplay;

                EditorGUIUtility.QueueGameViewInputEvent(Event.current);

                // Do not use mouse UP event if mousepos is outside game view rect (fix for case 380995: Gameview tab's context menu is not appearing on right click)
                // Placed after event queueing above to ensure scripts can react on mouse up events.
                bool useEvent = !(Event.current.rawType == EventType.MouseUp && !mousePosInGameViewRect);

                // Don't use command events, or they won't be sent to other views.
                if (type == EventType.ExecuteCommand || type == EventType.ValidateCommand)
                {
                    useEvent = false;
                }

                if (useEvent)
                {
                    Event.current.Use();
                }
                else
                {
                    Event.current.mousePosition = editorMousePosition;
                }

                // Reset display index
                Event.current.displayIndex = originalDisplayIndex;
            }

            m_ZoomArea.EndViewGUI();

            if (originalEventType == EventType.ScrollWheel && Event.current.type == EventType.Used)
            {
                EditorApplication.update -= SnapZoomDelayed;
                EditorApplication.update += SnapZoomDelayed;
                s_LastScrollTime          = EditorApplication.timeSinceStartup;
            }

            EnforceZoomAreaConstraints();

            if (m_RenderTexture)
            {
                if (m_ZoomArea.scale.y < 1f)
                {
                    m_RenderTexture.filterMode = FilterMode.Bilinear;
                }
                else
                {
                    m_RenderTexture.filterMode = FilterMode.Point;
                }
            }

            if (m_NoCameraWarning && !EditorGUIUtility.IsDisplayReferencedByCameras(targetDisplay))
            {
                GUI.Label(warningPosition, GUIContent.none, EditorStyles.notificationBackground);
                var displayName   = ModuleManager.ShouldShowMultiDisplayOption() ? DisplayUtility.GetDisplayNames()[targetDisplay].text : string.Empty;
                var cameraWarning = string.Format("{0}\nNo cameras rendering", displayName);
                EditorGUI.DoDropShadowLabel(warningPosition, EditorGUIUtility.TempContent(cameraWarning), EditorStyles.notificationText, .3f);
            }

            if (m_Stats)
            {
                GameViewGUI.GameViewStatsGUI();
            }
        }
示例#17
0
        private void AllRootCanvases()
        {
            if (VREditor.GetVREnabledOnTargetGroup(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget)) && (m_RenderMode.enumValueIndex == (int)RenderMode.ScreenSpaceOverlay))
            {
                EditorGUILayout.HelpBox("Using a render mode of ScreenSpaceOverlay while VR is enabled will cause the Canvas to continue to incur a rendering cost, even though the Canvas will not be visible in VR.", MessageType.Warning);
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(m_RenderMode);
            if (EditorGUI.EndChangeCheck())
            {
                var rectTransforms = targets.Select(c => (c as Canvas).transform).ToArray();
                Undo.RegisterCompleteObjectUndo(rectTransforms, "Modified RectTransform Values");
                serializedObject.ApplyModifiedProperties();
                foreach (Canvas canvas in targets)
                {
                    canvas.UpdateCanvasRectTransform(true);
                }
                GUIUtility.ExitGUI();
            }

            m_OverlayMode.target = m_RenderMode.intValue == 0;
            m_CameraMode.target  = m_RenderMode.intValue == 1;
            m_WorldMode.target   = m_RenderMode.intValue == 2;

            EditorGUI.indentLevel++;
            if (EditorGUILayout.BeginFadeGroup(m_OverlayMode.faded))
            {
                DoPixelPerfectGUIForRoot();

                EditorGUILayout.PropertyField(m_SortingOrder, Styles.sortingOrder);
                GUIContent[] displayNames = DisplayUtility.GetDisplayNames();
                EditorGUILayout.IntPopup(m_TargetDisplay, displayNames, DisplayUtility.GetDisplayIndices(), Styles.targetDisplay);
            }
            EditorGUILayout.EndFadeGroup();

            if (EditorGUILayout.BeginFadeGroup(m_CameraMode.faded))
            {
                DoPixelPerfectGUIForRoot();

                EditorGUILayout.PropertyField(m_Camera, Styles.renderCamera);

                if (m_Camera.objectReferenceValue == null)
                {
                    EditorGUILayout.HelpBox("A Screen Space Canvas with no specified camera acts like an Overlay Canvas.",
                                            MessageType.Warning);
                }

                if (m_Camera.objectReferenceValue != null)
                {
                    EditorGUILayout.PropertyField(m_PlaneDistance);
                    EditorGUILayout.PropertyField(m_UpdateRectTransformForStandalone, Styles.standaloneRenderResize);
                }

                EditorGUILayout.Space();

                if (m_Camera.objectReferenceValue != null)
                {
                    EditorGUILayout.SortingLayerField(Styles.m_SortingLayerStyle, m_SortingLayerID, EditorStyles.popup, EditorStyles.label);
                }
                EditorGUILayout.PropertyField(m_SortingOrder, Styles.m_SortingOrderStyle);
            }
            EditorGUILayout.EndFadeGroup();

            if (EditorGUILayout.BeginFadeGroup(m_WorldMode.faded))
            {
                EditorGUILayout.PropertyField(m_Camera, Styles.eventCamera);

                if (m_Camera.objectReferenceValue == null)
                {
                    EditorGUILayout.HelpBox("A World Space Canvas with no specified Event Camera may not register UI events correctly.",
                                            MessageType.Warning);
                }

                EditorGUILayout.Space();
                EditorGUILayout.SortingLayerField(Styles.m_SortingLayerStyle, m_SortingLayerID, EditorStyles.popup);
                EditorGUILayout.PropertyField(m_SortingOrder, Styles.m_SortingOrderStyle);
            }
            EditorGUILayout.EndFadeGroup();
            EditorGUI.indentLevel--;
        }