Move transform gizmo visibility to the base class

#3692
This commit is contained in:
Wojtek Figat
2026-02-03 16:46:46 +01:00
parent 07f21a1520
commit 0f383d2fc6
4 changed files with 16 additions and 17 deletions

View File

@@ -13,6 +13,7 @@ namespace FlaxEditor.Gizmo
public abstract class GizmoBase
{
private IGizmoOwner _owner;
private bool _visible = true;
/// <summary>
/// Gets the gizmo owner.
@@ -34,6 +35,11 @@ namespace FlaxEditor.Gizmo
/// </summary>
public virtual BoundingSphere FocusBounds => BoundingSphere.Empty;
/// <summary>
/// Gets or sets a value indicating whether this gizmo is visible.
/// </summary>
public bool Visible { get { return _visible; } set { _visible = value; } }
/// <summary>
/// Initializes a new instance of the <see cref="GizmoBase"/> class.
/// </summary>

View File

@@ -31,7 +31,6 @@ namespace FlaxEditor.Gizmo
private readonly List<SceneGraphNode> _selection = new List<SceneGraphNode>();
private readonly List<SceneGraphNode> _selectionParents = new List<SceneGraphNode>();
private bool _visible = true;
/// <summary>
/// The event to apply objects transformation.
@@ -53,11 +52,6 @@ namespace FlaxEditor.Gizmo
/// </summary>
public List<SceneGraphNode> SelectedParents => _selectionParents;
/// <summary>
/// Gets or sets a value indicating whether this <see cref="TransformGizmo"/> is visible.
/// </summary>
public bool Visible { get { return _visible; } set { _visible = value; } }
/// <summary>
/// Initializes a new instance of the <see cref="TransformGizmo" /> class.
/// </summary>
@@ -281,13 +275,6 @@ namespace FlaxEditor.Gizmo
base.OnSelectionChanged(newSelection);
}
/// <inheritdoc />
public override void Draw(ref RenderContext renderContext)
{
if (Visible)
base.Draw(ref renderContext);
}
/// <inheritdoc />
protected override int SelectionCount => _selectionParents.Count;

View File

@@ -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

View File

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