PointerEventData.pointerCurrentRaycast is null

Hey, Folk!

Can someone explain why PointerEventData.pointerCurrentRaycast is null, when i get PointerEventData during
public void OnPointerExit(EventSystems.PointerEventData eventData);

In documentation i can find “PointerEventData.pointerCurrentRaycast : RaycastResult associated with the current event.

And event triggered when i Pointer Exit some object, logicaly event “exit” is associated with this object. But pointerCurrentRaycast is null, and i can’t determinate which object pointer exit.

I’m guessing because when you’re not on an object, the raycast is by definition not hitting any object to return to you!

Instead, keep a reference of what object the pointer was on last frame, and when you are no longer on it, look at that last object and make your appropriate decisions from that.

And how can i determinate object which pointer exit?

It will be the object that is having its OnPointerExit method called.

I´m late, but you have to check if its null or not:

if(eventData.pointerCurrentRaycast.gameObject.GetComponent<Whatever>() != null)
{
     //your code
}