Change mouse cursor when element under it is clickable.

I want to change the cursor of the mouse when ever the mouse position is hovering above a clickable UI element.

I’v found some solutions but all of them i using the update function and iteration over a list or hovered gameObjects.

So my question is:
why isn’t there an event that just called with the currently hovered AND clickable element?
like: OnPointerEnter(GameObject hoveredGameObject);

Just like there are “enter” and “exit” events on each monobehavior, aren’t those objects are stored anywhere?

This is just weird I have to look for it with the update function and and use iterations for simply changing the mouse cursor.

Is there any better solution that I’ve missed?

Not done it before so not sure if this is what you need.
Can you add the event you want on the UI element from the inspector?
Add component/Event/Event Trigger
Add New Event Type

The problem here is that you need to implement it on every clickable element in the game.
I want something universal for all UI elements that are clickable in the game.
Like override the function that calls the functions on the UI element.

1 Like

True, but better than using an update function.
You could add it to a script startup, and attach the script to the UI elements you want to behave in this way.
If it’s all UI elements you could add the Event Trigger at scene load to all UI elements.
You could look at extending the UI elements but others have expressed some functionality issue with this

Well I’v found myself doing the script on each UI element option.

It is still kinda weird that I need to do that simply to swap the mouse cursor to clickable which is pretty standard feature if you ask me…

Thanks for the help.

1 Like