From b130b81863e069a9084426cf62a79a246a1d1277 Mon Sep 17 00:00:00 2001 From: Saas Date: Sat, 20 Sep 2025 15:08:03 +0200 Subject: [PATCH 1/6] add game view and show/ hiding navigation similar to unreal engine --- Source/Editor/Gizmo/TransformGizmo.cs | 13 +++++++++ Source/Editor/Options/InputOptions.cs | 8 +++++ .../Viewport/MainEditorGizmoViewport.cs | 29 +++++++++++++++++++ Source/Engine/Graphics/Enums.h | 5 ++++ 4 files changed, 55 insertions(+) diff --git a/Source/Editor/Gizmo/TransformGizmo.cs b/Source/Editor/Gizmo/TransformGizmo.cs index 8294a4302..d5847c892 100644 --- a/Source/Editor/Gizmo/TransformGizmo.cs +++ b/Source/Editor/Gizmo/TransformGizmo.cs @@ -31,6 +31,7 @@ namespace FlaxEditor.Gizmo private readonly List _selection = new List(); private readonly List _selectionParents = new List(); + private bool _visible = true; /// /// The event to apply objects transformation. @@ -52,6 +53,11 @@ namespace FlaxEditor.Gizmo /// public List SelectedParents => _selectionParents; + /// + /// Gets or sets a value indicating whether this is visible. + /// + public bool Visible { get { return _visible; } set { _visible = value; } } + /// /// Initializes a new instance of the class. /// @@ -272,6 +278,13 @@ namespace FlaxEditor.Gizmo base.OnSelectionChanged(newSelection); } + /// + public override void Draw(ref RenderContext renderContext) + { + if (Visible) + base.Draw(ref renderContext); + } + /// protected override int SelectionCount => _selectionParents.Count; diff --git a/Source/Editor/Options/InputOptions.cs b/Source/Editor/Options/InputOptions.cs index af919c1f3..1c6a8279d 100644 --- a/Source/Editor/Options/InputOptions.cs +++ b/Source/Editor/Options/InputOptions.cs @@ -387,6 +387,14 @@ namespace FlaxEditor.Options [EditorDisplay("Viewport"), EditorOrder(1760)] public InputBinding ToggleOrthographic = new InputBinding(KeyboardKeys.NumpadDecimal); + [DefaultValue(typeof(InputBinding), "G")] + [EditorDisplay("Viewport"), EditorOrder(1770)] + public InputBinding ToggleGameView = new InputBinding(KeyboardKeys.G); + + [DefaultValue(typeof(InputBinding), "P")] + [EditorDisplay("Viewport"), EditorOrder(1770)] + public InputBinding ToggleNavMeshVisibility = new InputBinding(KeyboardKeys.P); + #endregion #region Debug Views diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index bb01bc863..6f30977e2 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -108,6 +108,12 @@ namespace FlaxEditor.Viewport private EditorSpritesRenderer _editorSpritesRenderer; private ViewportRubberBandSelector _rubberBandSelector; + private bool _gameViewActive; + private ViewFlags _preGameViewFlags; + private bool _gameViewWasGridShown; + private bool _gameViewWasFpsCounterShown; + private bool _gameViewWasNagivationShown; + /// /// Drag and drop handlers /// @@ -259,6 +265,29 @@ namespace FlaxEditor.Viewport InputActions.Add(options => options.FocusSelection, FocusSelection); InputActions.Add(options => options.RotateSelection, RotateSelection); InputActions.Add(options => options.Delete, _editor.SceneEditing.Delete); + 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; + }); } /// diff --git a/Source/Engine/Graphics/Enums.h b/Source/Engine/Graphics/Enums.h index 6343b827b..9019fc504 100644 --- a/Source/Engine/Graphics/Enums.h +++ b/Source/Engine/Graphics/Enums.h @@ -1082,6 +1082,11 @@ API_ENUM(Attributes="Flags") enum class ViewFlags : uint64 /// Default flags for materials/models previews generating. /// DefaultAssetPreview = Reflections | Decals | DirectionalLights | PointLights | SpotLights | SkyLights | SpecularLight | AntiAliasing | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | ContactShadows | Sky, + + /// + /// 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, }; DECLARE_ENUM_OPERATORS(ViewFlags); From fd1e0a4e80eabf0c308c29f5357ade9031c626a7 Mon Sep 17 00:00:00 2001 From: Saas Date: Sat, 20 Sep 2025 16:12:04 +0200 Subject: [PATCH 2/6] add game view to "View" menu, add keyboard new keyboard shortcuts to menu and extra options for view flags and view layers --- Source/Editor/Viewport/EditorViewport.cs | 8 ++- .../Viewport/MainEditorGizmoViewport.cs | 56 ++++++++++++------- Source/Engine/Graphics/Enums.h | 5 ++ 3 files changed, 46 insertions(+), 23 deletions(-) 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); From 6e9902a9668ec122c45179e78a36a45878d1061a Mon Sep 17 00:00:00 2001 From: Saas Date: Sun, 21 Sep 2025 16:49:07 +0200 Subject: [PATCH 3/6] use DefaultGame ViewFlag and some fixes --- Source/Editor/Viewport/MainEditorGizmoViewport.cs | 8 ++++---- Source/Engine/Graphics/Enums.h | 5 ----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index f882505b3..9e37b3dce 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -499,12 +499,12 @@ namespace FlaxEditor.Viewport if (!_gameViewActive) { _preGameViewFlags = Task.ViewFlags; - _gameViewWasGridShown = ShowFpsCounter; - _gameViewWasFpsCounterShown = ShowNavigation; - _gameViewWasNagivationShown = Grid.Enabled; + _gameViewWasGridShown = Grid.Enabled; + _gameViewWasFpsCounterShown = ShowFpsCounter; + _gameViewWasNagivationShown = ShowNavigation; } - Task.ViewFlags = _gameViewActive ? _preGameViewFlags : ViewFlags.GameView; + Task.ViewFlags = _gameViewActive ? _preGameViewFlags : ViewFlags.DefaultGame; ShowFpsCounter = _gameViewActive ? _gameViewWasGridShown : false; ShowNavigation = _gameViewActive ? _gameViewWasFpsCounterShown : false; Grid.Enabled = _gameViewActive ? _gameViewWasNagivationShown : false; diff --git a/Source/Engine/Graphics/Enums.h b/Source/Engine/Graphics/Enums.h index f61096863..3df3194d4 100644 --- a/Source/Engine/Graphics/Enums.h +++ b/Source/Engine/Graphics/Enums.h @@ -1083,11 +1083,6 @@ API_ENUM(Attributes="Flags") enum class ViewFlags : uint64 /// DefaultAssetPreview = Reflections | Decals | DirectionalLights | PointLights | SpotLights | SkyLights | SpecularLight | AntiAliasing | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | ContactShadows | Sky, - /// - /// 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. /// From 13dd80d4290fd6743ff3dfadd6c19f973e114309 Mon Sep 17 00:00:00 2001 From: Saas Date: Sun, 21 Sep 2025 16:57:38 +0200 Subject: [PATCH 4/6] add changing and caching Debug ViewMode for Game View --- Source/Editor/Viewport/EditorViewport.cs | 6 +++--- Source/Editor/Viewport/MainEditorGizmoViewport.cs | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/Editor/Viewport/EditorViewport.cs b/Source/Editor/Viewport/EditorViewport.cs index ed4832d63..4502880cb 100644 --- a/Source/Editor/Viewport/EditorViewport.cs +++ b/Source/Editor/Viewport/EditorViewport.cs @@ -584,7 +584,7 @@ namespace FlaxEditor.Viewport _cameraButton = new ViewportWidgetButton(string.Format(MovementSpeedTextFormat, _movementSpeed), Editor.Instance.Icons.Camera64, cameraCM, false, cameraSpeedTextWidth) { Tag = this, - TooltipText = "Camera Settings", + TooltipText = "Camera Settings.", Parent = _cameraWidget }; _cameraWidget.Parent = this; @@ -593,7 +593,7 @@ namespace FlaxEditor.Viewport _orthographicModeButton = new ViewportWidgetButton(string.Empty, Editor.Instance.Icons.CamSpeed32, null, true) { Checked = !_isOrtho, - TooltipText = "Toggle Orthographic/Perspective Mode", + TooltipText = "Toggle Orthographic/Perspective Mode.", Parent = _cameraWidget }; _orthographicModeButton.Toggled += OnOrthographicModeToggled; @@ -832,7 +832,7 @@ namespace FlaxEditor.Viewport ViewWidgetButtonMenu = new ContextMenu(); var viewModeButton = new ViewportWidgetButton("View", SpriteHandle.Invalid, ViewWidgetButtonMenu) { - TooltipText = "View properties", + TooltipText = "View properties.", Parent = viewMode }; viewMode.Parent = this; diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index 9e37b3dce..f9b382a0a 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -111,6 +111,7 @@ namespace FlaxEditor.Viewport private bool _gameViewActive; private ViewFlags _preGameViewFlags; + private ViewMode _preGameViewViewMode; private bool _gameViewWasGridShown; private bool _gameViewWasFpsCounterShown; private bool _gameViewWasNagivationShown; @@ -499,12 +500,14 @@ namespace FlaxEditor.Viewport if (!_gameViewActive) { _preGameViewFlags = Task.ViewFlags; + _preGameViewViewMode = Task.ViewMode; _gameViewWasGridShown = Grid.Enabled; _gameViewWasFpsCounterShown = ShowFpsCounter; _gameViewWasNagivationShown = ShowNavigation; } Task.ViewFlags = _gameViewActive ? _preGameViewFlags : ViewFlags.DefaultGame; + Task.ViewMode = _gameViewActive ? _preGameViewViewMode : ViewMode.Default; ShowFpsCounter = _gameViewActive ? _gameViewWasGridShown : false; ShowNavigation = _gameViewActive ? _gameViewWasFpsCounterShown : false; Grid.Enabled = _gameViewActive ? _gameViewWasNagivationShown : false; From 26e24769bea94f4b3d73a283c582a6d2c05c67a5 Mon Sep 17 00:00:00 2001 From: Saas Date: Thu, 11 Dec 2025 20:44:40 +0100 Subject: [PATCH 5/6] actually set things to the right thing How the hell did this happen?? --- Source/Editor/Viewport/MainEditorGizmoViewport.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index f9b382a0a..66e1b5210 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -499,6 +499,7 @@ namespace FlaxEditor.Viewport { if (!_gameViewActive) { + // Cache flags & values _preGameViewFlags = Task.ViewFlags; _preGameViewViewMode = Task.ViewMode; _gameViewWasGridShown = Grid.Enabled; @@ -506,11 +507,12 @@ namespace FlaxEditor.Viewport _gameViewWasNagivationShown = ShowNavigation; } + // Set flags & values Task.ViewFlags = _gameViewActive ? _preGameViewFlags : ViewFlags.DefaultGame; Task.ViewMode = _gameViewActive ? _preGameViewViewMode : ViewMode.Default; - ShowFpsCounter = _gameViewActive ? _gameViewWasGridShown : false; - ShowNavigation = _gameViewActive ? _gameViewWasFpsCounterShown : false; - Grid.Enabled = _gameViewActive ? _gameViewWasNagivationShown : false; + ShowFpsCounter = _gameViewActive ? _gameViewWasFpsCounterShown : false; + ShowNavigation = _gameViewActive ? _gameViewWasNagivationShown : false; + Grid.Enabled = _gameViewActive ? _gameViewWasGridShown : false; _gameViewActive = !_gameViewActive; From 0f383d2fc694c6ba751ce40cb0f2f8618a95b842 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 3 Feb 2026 16:46:46 +0100 Subject: [PATCH 6/6] Move transform gizmo visibility to the base class #3692 --- Source/Editor/Gizmo/GizmoBase.cs | 6 ++++++ Source/Editor/Gizmo/TransformGizmo.cs | 13 ------------- Source/Editor/Viewport/MainEditorGizmoViewport.cs | 7 +++++-- Source/Editor/Viewport/PrefabWindowViewport.cs | 7 +++++-- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Source/Editor/Gizmo/GizmoBase.cs b/Source/Editor/Gizmo/GizmoBase.cs index 57cd62d79..80c3e5012 100644 --- a/Source/Editor/Gizmo/GizmoBase.cs +++ b/Source/Editor/Gizmo/GizmoBase.cs @@ -13,6 +13,7 @@ namespace FlaxEditor.Gizmo public abstract class GizmoBase { private IGizmoOwner _owner; + private bool _visible = true; /// /// Gets the gizmo owner. @@ -34,6 +35,11 @@ namespace FlaxEditor.Gizmo /// public virtual BoundingSphere FocusBounds => BoundingSphere.Empty; + /// + /// Gets or sets a value indicating whether this gizmo is visible. + /// + public bool Visible { get { return _visible; } set { _visible = value; } } + /// /// Initializes a new instance of the class. /// diff --git a/Source/Editor/Gizmo/TransformGizmo.cs b/Source/Editor/Gizmo/TransformGizmo.cs index 3e4a193a4..91e37ca25 100644 --- a/Source/Editor/Gizmo/TransformGizmo.cs +++ b/Source/Editor/Gizmo/TransformGizmo.cs @@ -31,7 +31,6 @@ namespace FlaxEditor.Gizmo private readonly List _selection = new List(); private readonly List _selectionParents = new List(); - private bool _visible = true; /// /// The event to apply objects transformation. @@ -53,11 +52,6 @@ namespace FlaxEditor.Gizmo /// public List SelectedParents => _selectionParents; - /// - /// Gets or sets a value indicating whether this is visible. - /// - public bool Visible { get { return _visible; } set { _visible = value; } } - /// /// Initializes a new instance of the class. /// @@ -281,13 +275,6 @@ namespace FlaxEditor.Gizmo base.OnSelectionChanged(newSelection); } - /// - public override void Draw(ref RenderContext renderContext) - { - if (Visible) - base.Draw(ref renderContext); - } - /// protected override int SelectionCount => _selectionParents.Count; diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index 396c38c07..3d366809c 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -391,9 +391,12 @@ namespace FlaxEditor.Viewport public void DrawEditorPrimitives(GPUContext context, ref RenderContext renderContext, GPUTexture target, GPUTexture targetDepth) { // Draw gizmos - for (int i = 0; i < Gizmos.Count; i++) + foreach (var gizmo in Gizmos) { - Gizmos[i].Draw(ref renderContext); + if (gizmo.Visible) + { + gizmo.Draw(ref renderContext); + } } // Draw selected objects debug shapes and visuals diff --git a/Source/Editor/Viewport/PrefabWindowViewport.cs b/Source/Editor/Viewport/PrefabWindowViewport.cs index a22b4042f..7f2b1a471 100644 --- a/Source/Editor/Viewport/PrefabWindowViewport.cs +++ b/Source/Editor/Viewport/PrefabWindowViewport.cs @@ -720,9 +720,12 @@ namespace FlaxEditor.Viewport public override void DrawEditorPrimitives(GPUContext context, ref RenderContext renderContext, GPUTexture target, GPUTexture targetDepth) { // Draw gizmos - for (int i = 0; i < Gizmos.Count; i++) + foreach (var gizmo in Gizmos) { - Gizmos[i].Draw(ref renderContext); + if (gizmo.Visible) + { + gizmo.Draw(ref renderContext); + } } base.DrawEditorPrimitives(context, ref renderContext, target, targetDepth);