Why isn't there a simple way to check, if the pointer is over any ui object?

I wonder why there isn’t a method like “IsPointerOverUI” somewhere in unity. Maybe as a public method of Canvas or at any other available location. It seems that there is no satisfying solution to get this information … or I’m unable to find it.
And I don’t talk about adding custom scripts to each UI element to set a flag when the pointer is over that element or something like that. That all is too elaborate.

Please let me now if I’m wrong and there is a easy way or give us this function in the next release!

Thanks in advance for all your answers


Try this one.

But, you might have see this will not work on non-event UI elements. like simple image or text components. To make it work in any UI element -

  • Add a Button with empty action.

  • Transition = None.

  • And that’s it.

now it works with any UI element.

more help :

@Pratap-Dafedar You are a genius! This is the exact answer I was looking for.
I’ve been banging my head against the wall because of this problem.
Some UI elements worked with isPointerOverGameObject and some didn’t and I couldn’t figure out why but you my friend answered it for me.

Thanks bro.