How to attach hover event to Button?

HI,

I have a UI Button.
Can I attach a hover event listener to it like “onClick.AddListener()”?
Or how to create a hover event for a button in new UI?

Very simple you can attach an Event Trigger ( Script ) to your GameObject.


143342-doublekick.png


Hovering in out of that object will trigger your specified function.

1 Like

You need to write your own script that implements the events IPointerEnterHandler and IPointerExitHandler, then attach it to the button object.

Add an EventTrigger (Pointer Enter type).

174386-untitled.png

Change Transition of Button component to “Sprite Swap”

OnHover custom event UnityEvent type