Unity 2018 Cookbook(Third Edition)
上QQ阅读APP看书,第一时间看更新

How it works...

You have created a button, and set its Transition mode to Animation. This makes Unity require an Animation Controller with four states: Normal, Highlighted, Pressed, and Disabled. You then made Unity automatically create an Animation Controller with these four states.

Then, you edited the Animation for the Highlighted (mouse-over) state, deleting the second keyframe, and making the only keyframe a version of the Button made larger to a scale of 1.2.

When the mouse is not over the Button, it's unchanged and Normal state settings are used. When the mouse moves over the Button, the Animation Controller smoothly in-betweens the settings of the Button to become those of its Highlighted state (that is, bigger). When the mouse is moved away from the Button, the Animation Controller smoothly in-betweens the settings of the Button to become those of its Normal state (that is, its original size).

The following web pages offer video and web-based tutorials on UI animations:

The Unity button transitions tutorial is available at  http://unity3d.com/learn/tutorials/modules/beginner/ui/ui-transitions.

Ray Wenderlich's great tutorial (part 2), including the button animations, is available at  http://www.raywenderlich.com/79031/unity-new-gui-tutorial-part-2.