How to make buttons fade between modes?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By rayohvv

What’s the best way to have my buttons transition between normal/focused/hovered with a fade animation?

Preferably so I can choose which scenes this effect will happen on.

Maybe you can use the signals on the Texture Button to detect what kind of UI changed occurred (lost/gained focus, stopped hovering, pressed, etc etc) and animate a Texture Rect associated with the Texture Button (instead of directly animating the Texture Button, because I am not seeing how to directly animate the texture of a texture button without animating the whole button)

BigTuna675 | 2022-10-07 22:32

This works but I need it on a regular button, I don’t think it’s possible though

rayohvv | 2022-10-08 13:03

A regular button has the same signals as a texture button, and instead of using an icon for the button you can use a texture rect that is childed to the button, and handle the animations in your own way using an animation player

BigTuna675 | 2022-10-08 13:13

Oh wow that works perfectly thank you!

rayohvv | 2022-10-08 13:42

Awesome! That’s good to hear because when I first read your question I was pretty stumped to be honest. I’m going to add an answer now so this doesn’t appear in the “unanswered” section anymore

BigTuna675 | 2022-10-08 13:48

:bust_in_silhouette: Reply From: BigTuna675

Like we discussed in the replies, for future readers, the solution was to use the signals from the button node to keep track of UI events (focus lost/gained, mouse hovering or not, etc), and then use an animation player node in conjunction with a childed texture rect to make custom animations

Okay one problem, I thought the animation player could fade between textures but it can’t, I instead used 2 texture rects and used a tween on the 2nd rect’s modulate alpha channel and it works, I’ll see if I have a problem with this method

rayohvv | 2022-10-08 14:53