Animating a button when the cursor is over it

In this recipe, you will learn how to animate a button when the cursor is over it. You will also learn how to use an Animator controller to handle generated animations from the Button (Script) component and how to change these animations.

How to do it...

  1. First of all, we have to create a UI button. Right-click on the Hierarchy panel, then go to UI | Button, and rename it Animated Button. Of course, it is possible to resize, change Source Image, the text, and place it as we wish.
  2. Now, we need to change the Transition mode in order to use a controller to animate it. In the Button (Script) component, click on Transition and select Animation. If you don't want to create a controller from scratch, click on ...

Get Unity UI Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.