UI Buttons Hover events

Hey guys,
I Have made three buttons, each having their own sprite attached. I have then made a hover image for each button, that I am trying to enable / disable whenever each button is being hovered over.

I have added the EventTrigger component to each button, and made each hover image a child of it’s respective button. Also been using OnPointerEnter / OnPointerExit but cannot make it work. Would greatly appreciate if somebody could point me in the right direction :slight_smile:

5261993--526406--Buttons.PNG

Are you using standard Unity UI Button? If so, there’s already slot for hover sprite in the inspector but you need to chage transition from color tint to sprite swap.

And if you want to see how Unity did it in their UI.Button class, the full source code is open for you to inspect and enjoy!

https://bitbucket.org/Unity-Technologies/ui/src/2019.1/

1 Like