Animation Events

One of my favorite things about Animation Clips is the ability to add Animation Events to frames on the timeline. Animation Events allow you to call functions that exist on the GameObject at specified frames. They are represented by white flags above the timeline, and hovering over them will show the name of the function called by the Animation Event.

An Animation Event can only call a function that exists somewhere on the GameObject the Animation Clip is attached to. The function can be public or private and can also have a parameter. The parameter can be of the following types:

  • float
  • int
  • string
  • An object reference
  • An AnimationEvent object

You can add an Animation Event to the Animation Clip's timeline by right-clicking ...

Get Mastering UI Development with Unity 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.