Is there a way to access the object hovered by a XR Ray Interactor ?

I’m trying to use the xr ray interactor of my XRHandController like a finger that would “touch” object and UI.
I’m thinking of shortening the ray range and using the Interactor Event “Hover entenred” that has a HoverEnterEventArgs.

But I only have experience with unity events that fires without args, how do I listen to this event and get the gameobject hovered ?

You need to make the method signature of the method you want to call accept the HoverEnterEventArgs or HoverExitEventArgs as a parameter. For example:

using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;

public class MyEventHandler : MonoBehaviour
{
    public void OnHoverEntered(HoverEnterEventArgs args)
    {
        Debug.Log($"{args.interactorObject} hovered over {args.interactableObject}", this);
    }

    public void OnHoverExited(HoverExitEventArgs args)
    {
        Debug.Log($"{args.interactorObject} stopped hovering over {args.interactableObject}", this);
    }
}

There should be two sections in the dropdown to select the method to call, Dynamic and Static Parameters. You should see OnHoverEntered or OnHoverExited under the Dynamic section at the top since it has the same method parameters that are raised by the event. Use those and the args will contain the interactor and interactable involved with the event. For more information about that, see UnityEvents in the manual.

Thank you !

also thank you. this is a neat trick