How do I animate a button in Unity 2D?

Viewed 854

I want to make a button shrink when pressed, then go back to its normal size when I stop pressing it. I changed the transition of the button to animation, I recorded an animation that goes form normal scale to 0.95, one that goes back to scale 1, I added the conditions, the button does shrinks when clicked, but remains shrunk after I move the mouse. Can somebody help me?

1 Answers

I would suggest following this tutorial video all the way through in order to ensure you understand how to fully animate the buttons. It's very detailed and will even show you some other tricks. If you've watched this and fully understand how animating buttons works, here is the answer to your specific problem (I don't think the tutorial video explicitly explains how to do what you want):

When you select the button, it will go into it's selected animation and stay there until you deselect the button. Therefore if the animation shrinks the button, it will simply stay at that size until you deselect the button (at which point it should return to the 'Normal Trigger' animation).

If you want it to always return to the normal state even when still selected, then you must add a return to normal size animation to your 'Pressed Trigger' (Button_Selected animation in the video) animation. Therefore your 'Pressed Trigger' animation should animate the button to 0.95 and then in the same amount of time, return to 1, all in the same animation.

Related