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);