diff --git a/Source/Editor/Viewport/EditorViewport.cs b/Source/Editor/Viewport/EditorViewport.cs index b4af43281..ed4832d63 100644 --- a/Source/Editor/Viewport/EditorViewport.cs +++ b/Source/Editor/Viewport/EditorViewport.cs @@ -864,7 +864,9 @@ namespace FlaxEditor.Viewport } }); viewLayers.AddButton("Reset layers", () => Task.ViewLayersMask = LayersMask.Default).Icon = Editor.Instance.Icons.Rotate32; - viewLayers.AddButton("Disable layers", () => Task.ViewLayersMask = new LayersMask(0)).Icon = Editor.Instance.Icons.Rotate32; + viewLayers.AddSeparator(); + viewLayers.AddButton("Enable all", () => Task.ViewLayersMask = new LayersMask(-1)).Icon = Editor.Instance.Icons.CheckBoxTick12; + viewLayers.AddButton("Disable all", () => Task.ViewLayersMask = new LayersMask(0)).Icon = Editor.Instance.Icons.Cross12; viewLayers.AddSeparator(); var layers = LayersAndTagsSettings.GetCurrentLayers(); if (layers != null && layers.Length > 0) @@ -905,7 +907,9 @@ namespace FlaxEditor.Viewport } }); viewFlags.AddButton("Reset flags", () => Task.ViewFlags = ViewFlags.DefaultEditor).Icon = Editor.Instance.Icons.Rotate32; - viewFlags.AddButton("Disable flags", () => Task.ViewFlags = ViewFlags.None).Icon = Editor.Instance.Icons.Rotate32; + viewFlags.AddSeparator(); + viewFlags.AddButton("Enable all", () => Task.ViewFlags = ViewFlags.All).Icon = Editor.Instance.Icons.CheckBoxTick12; + viewFlags.AddButton("Disable all", () => Task.ViewFlags = ViewFlags.None).Icon = Editor.Instance.Icons.Cross12; viewFlags.AddSeparator(); for (int i = 0; i < ViewFlagsValues.Length; i++) { diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index 6f30977e2..f882505b3 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -25,6 +25,7 @@ namespace FlaxEditor.Viewport private readonly Editor _editor; private readonly ContextMenuButton _showGridButton; private readonly ContextMenuButton _showNavigationButton; + private readonly ContextMenuButton _toggleGameViewButton; private SelectionOutline _customSelectionOutline; /// @@ -191,6 +192,7 @@ namespace FlaxEditor.Viewport : base(Object.New(), editor.Undo, editor.Scene.Root) { _editor = editor; + var inputOptions = _editor.Options.Options.Input; DragHandlers = new ViewportDragHandlers(this, this, ValidateDragItem, ValidateDragActorType, ValidateDragScriptItem); // Prepare rendering task @@ -238,9 +240,14 @@ namespace FlaxEditor.Viewport _showGridButton.CloseMenuOnClick = false; // Show navigation widget - _showNavigationButton = ViewWidgetShowMenu.AddButton("Navigation", () => ShowNavigation = !ShowNavigation); + _showNavigationButton = ViewWidgetShowMenu.AddButton("Navigation", inputOptions.ToggleNavMeshVisibility, () => ShowNavigation = !ShowNavigation); _showNavigationButton.CloseMenuOnClick = false; + // Game View + ViewWidgetButtonMenu.AddSeparator(); + _toggleGameViewButton = ViewWidgetButtonMenu.AddButton("Game View", inputOptions.ToggleGameView, ToggleGameView); + _toggleGameViewButton.CloseMenuOnClick = false; + // Create camera widget ViewWidgetButtonMenu.AddSeparator(); ViewWidgetButtonMenu.AddButton("Create camera here", CreateCameraAtView); @@ -268,26 +275,7 @@ namespace FlaxEditor.Viewport InputActions.Add(options => options.ToggleNavMeshVisibility, () => ShowNavigation = !ShowNavigation); // Game View - InputActions.Add(options => options.ToggleGameView, () => - { - if (!_gameViewActive) - { - _preGameViewFlags = Task.ViewFlags; - _gameViewWasGridShown = ShowFpsCounter; - _gameViewWasFpsCounterShown = ShowNavigation; - _gameViewWasNagivationShown = Grid.Enabled; - } - - Task.ViewFlags = _gameViewActive ? _preGameViewFlags : ViewFlags.GameView; - ShowFpsCounter = _gameViewActive ? _gameViewWasGridShown : false; - ShowNavigation = _gameViewActive ? _gameViewWasFpsCounterShown : false; - Grid.Enabled = _gameViewActive ? _gameViewWasNagivationShown : false; - - _gameViewActive = !_gameViewActive; - - TransformGizmo.Visible = !_gameViewActive; - SelectionOutline.ShowSelectionOutline = !_gameViewActive; - }); + InputActions.Add(options => options.ToggleGameView, ToggleGameView); } /// @@ -503,6 +491,32 @@ namespace FlaxEditor.Viewport TransformGizmo.EndTransforming(); } + /// + /// Toggles game view view mode on or off. + /// + public void ToggleGameView() + { + if (!_gameViewActive) + { + _preGameViewFlags = Task.ViewFlags; + _gameViewWasGridShown = ShowFpsCounter; + _gameViewWasFpsCounterShown = ShowNavigation; + _gameViewWasNagivationShown = Grid.Enabled; + } + + Task.ViewFlags = _gameViewActive ? _preGameViewFlags : ViewFlags.GameView; + ShowFpsCounter = _gameViewActive ? _gameViewWasGridShown : false; + ShowNavigation = _gameViewActive ? _gameViewWasFpsCounterShown : false; + Grid.Enabled = _gameViewActive ? _gameViewWasNagivationShown : false; + + _gameViewActive = !_gameViewActive; + + TransformGizmo.Visible = !_gameViewActive; + SelectionOutline.ShowSelectionOutline = !_gameViewActive; + + _toggleGameViewButton.Icon = _gameViewActive ? Style.Current.CheckBoxTick : SpriteHandle.Invalid; + } + /// public override void OnLostFocus() { diff --git a/Source/Engine/Graphics/Enums.h b/Source/Engine/Graphics/Enums.h index 9019fc504..f61096863 100644 --- a/Source/Engine/Graphics/Enums.h +++ b/Source/Engine/Graphics/Enums.h @@ -1087,6 +1087,11 @@ API_ENUM(Attributes="Flags") enum class ViewFlags : uint64 /// Default flags for game view. /// GameView = AntiAliasing | Shadows | Reflections | SSR | AO | GI | DirectionalLights | PointLights | SpotLights | SkyLights | Sky | Fog | SpecularLight | Decals | CustomPostProcess | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | MotionBlur | ContactShadows | DepthOfField, + + /// + /// All flags enabled. + /// + All = None | DebugDraw | EditorSprites | Reflections | SSR | AO | GI | DirectionalLights | PointLights | SpotLights | SkyLights | Shadows | SpecularLight | AntiAliasing | CustomPostProcess | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | Decals | DepthOfField | PhysicsDebug | Fog | MotionBlur | ContactShadows | GlobalSDF | Sky | LightsDebug, }; DECLARE_ENUM_OPERATORS(ViewFlags);