Using Animation Events
The Animation View lets you add Animation Events to Animation Clips. Animation Events lets you call a script function similar to SendMessage as part of playing back an animation.
Animation Events support functions that take zero or one parameter. The parameter can be a float, a string, an object reference, or an AnimationEvent. In the case of functions that take an AnimationEvent as parameter, both a float, a string, and an object reference can be specified. These three will be passed as member variables of the AnimationEvent.
// This JavaScript function can be called by an Animation Event function PrintFloat (theValue : float) { Debug.Log ("PrintFloat is called with a value of " + theValue); }
An Animation Event can be added to an Animation Clip at the currently previewed frame by clicking the or at any given frame by double-clicking the at the frame where the Animation Event should be. It is also possible to add an Animation Event by right-clicking the and select from the context menu. Once placed, Animation Events can be dragged around with the mouse. It is also possible to select multiple Animation Events to drag at once. Animation Events can be deleted by selecting them and pressing , or by right-clicking on them and selecting from the context menu.
Animation Events are shown in the . Add a new Animation Event by double-clicking the or by using the .
Adding an Animation Event will add a in the and open a Animation Event dialog. In the dialog you can specify which script function to call and fill in the parameter value to pass to the function.
The Animation Event popup dialog lets you specify which function to call and fill in the parameter values.
All the Animation Events in an Animation Clip are shown as in the . You can quickly get see what a specific Animation Event does by holding the mouse cursor over the .
Holding the mouse cursor over an will show which function it calls as well as the parameter value.