Accessing the Hovered Gizmo

In order to get access to the currently hovered gizmo, you need to use the RTGizmosEngine class:

// Get a reference to the hovered gizmo
// Note: If no gizmo is hovered, the HoveredGizmo property returns null.
Gizmo hoveredGizmo = RTGizmosEngine.Get.HoveredGizmo;

If the returned value is null, it means no gizmo is hovered.

Note

There will always be ONE gizmo hovered at any one time.

Gizmo Hover State

You can check if a gizmo is hovered using the Gizmo.IsHovered property:

if (gizmo.IsHovered)
{
    // Do stuff
}

You can use this property to check if a specific gizmo is hovered. For example, the following code will check if either one of the move or rotation gizmos are hovered.

Gizmo moveGizmo = RTObjectSelectionGizmos.Get.GetGizmoById(ObjectSelectionGizmoId.MoveGizmo);
Gizmo rotationGizmo = RTObjectSelectionGizmos.Get.GetGizmoById(ObjectSelectionGizmoId.RotationGizmo);
if (moveGizmo.IsHovered || rotationGizmo.IsHovered)
{
    // Do stuff
}

Note

When the IsHovered property returns false, all other hover related properties (discussed next) should be ignored.

Hover Handle Information

You can also retrieve information about the hovered handle:

// Get the id of the hovered gizmo handle
// Note: If the gizmo is not hovered, the HoverHandleId property will return GizmoHandleId.None;
int hoverHandleId = gizmo.HoverHandleId;

// Get the dimension of the hovered gizmo handle
// Note: If the gizmo is not hovered, the HoverHandleDimension property will return GizmoDimension.None;
GizmoDimension hoverHandleDim = gizmo.HoverHandleDimension;

As indicated by the comments, when the gizmo is not hovered the HoverHandleId and HoverHandleDimension properties will return a None value.

Hover Point

It may sometimes be useful to know the intersection point between the mouse cursor and the hovered gizmo handle. This can be done using the HoverPoint property:

Vector3 hoverPoint = gizmo.HoverPoint;

Note

The hover point is a 3D point in the 3D world if the hovered handle is a 3D handle. But if the hovered handle is a 2D handle, the hover point is a 2D point in screen space. If you need to make any decisions in code based on the hover point, it might first be useful to check the dimension of the hover handle first:

if (gizmo.HoverHandleDimension == GizmoDimension.Dim3D)
{
    // Implement logic for a **3D** hover point
}
else
if (gizmo.HoverHandleDimension == GizmoDimension.Dim2D)
{   
    // Implement logic for a **2D** hover point (a point expressed in screen space coordinates)
}
else 
{
    // GizmoDimension.None - this means the gizmo is not hovered
}

The GizmoHoverInfo Struct

You can also retrieve an instance of the GizmoHoverInfo struct to get access to all hover related states at once:

GizmolHoverInfo hoverInfo = gizmo.HoverInfo;

This struct exposes the following properties:

public struct GizmoHoverInfo
{
    public bool IsHovered { get { return _isHovered; } set { _isHovered = value; } }
    public int HandleId { get { return _handleId; } set { _handleId = value; } }
    public GizmoDimension HandleDimension { get { return _handleDimension; } set { _handleDimension = value; } }
    public Vector3 HoverPoint { get { return _hoverPoint; } set { _hoverPoint = value; } }
}

These are the same as the properties that can be accessed via the Gizmo class properties which have already been discussed in earlier sections.