How it works...

This recipe has a few key elements that make it work:

  • Button Animator Controller: When you click on the Auto Generate Animation button, not only the Animation Clips are created, but also an Animator Controller is. It is also automatically assigned to the button (along with an Animator component). All the transitions between animation states in the Animator Controller are also already set up. Unity also creates parameters in the Animator Controller for you-those are the Trigger parameters used for transitions between the button states.
  • Calling the Triggers: You can find four properties in the Button component: Normal TriggerHighlighted TriggerPressed Trigger, and DisabledTrigger. Unity will try to call those triggers in ...

Get Unity 5.x Animation Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.