// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. using System.Collections.Generic; using FlaxEditor.SceneGraph; using FlaxEngine; namespace FlaxEditor.Gizmo { /// /// Base class for all Gizmo controls that can be attached to the . /// [HideInEditor] public abstract class GizmoBase { /// /// Gets the gizmo owner. /// public IGizmoOwner Owner { get; } /// /// Gets a value indicating whether this gizmo is active. /// public bool IsActive => Owner.Gizmos.Active == this; /// /// Gets a value indicating whether this gizmo is using mouse currently (eg. user moving objects). /// public virtual bool IsControllingMouse => false; /// /// Gets the custom world-space bounds for current gizmo mode focus for used (eg. selected object part bounds). Returns if not used. /// public virtual BoundingSphere FocusBounds => BoundingSphere.Empty; /// /// Initializes a new instance of the class. /// /// The gizmos owner. protected GizmoBase(IGizmoOwner owner) { // Link Owner = owner; Owner.Gizmos.Add(this); } /// /// Called when selected objects collection gets changed. /// /// The new selection pool. public virtual void OnSelectionChanged(List newSelection) { } /// /// Called when gizmo gets activated. /// public virtual void OnActivated() { } /// /// Called when gizmo gets deactivated. /// public virtual void OnDeactivated() { } /// /// Updates the gizmo logic (called even if not active). /// /// Update delta time (in seconds). public virtual void Update(float dt) { } /// /// Performs scene object picking. Called by the viewport on left mouse button released. /// public virtual void Pick() { } /// /// Performs scene objects snapping to the ground. /// public virtual void SnapToGround() { } /// /// Draws the gizmo. /// /// The rendering context. public virtual void Draw(ref RenderContext renderContext) { } } }