Get XR controller from PointerEventData? (Tooltip system)

Hello,
I have a ToolTip system which works with the IPointerEnterHandler and IPointerExitHandler interfaces.

The events pass the PointerEventData class. Is there any way to use this information to detect which XR controller (left or right) caused the pointer event, so that I can show the tooltip in the correct hand?

I found the answer in a different thread:

    public void OnPointerEnter(PointerEventData eventData)
    {
        if (eventData is TrackedDeviceEventData trackedDeviceEventData)
        {
            if (trackedDeviceEventData.interactor is XRBaseControllerInteractor xrInteractor)
            {
                // Your code, for example haptic or compare the interactor to left / right
                xrInteractor.SendHapticImpulse(0.25f, 0.25f);
            }
        }
    }
2 Likes