- Home /
Other
Animation Events, how is the parameter "AnimationEvent" used?
Hey there, I can't find an explanation for this part of the documentation:
The parameter can be a float, an int, a string, an object reference, or an AnimationEvent.
Anyone know exactly how you go about passing an animation event into a function and how that could be used practically in code?
Can't find anything other than this:
http://docs.unity3d.com/Manual/animeditor-AnimationEvents.html
which doesn't exactly get emotional over the details.
Thanks very much!
Romano
Answer by julang · Nov 13, 2014 at 06:59 AM
I just discovered this. You can simply have a single AnimationEvent parameter in your event handler function.
public void MyAnimationEventHandler (AnimationEvent animationEvent)
{
string stringParm = animationEvent.stringParameter;
float floatParam = animationEvent.floatParameter;
int intParam = animationEvent.intParameter;
// Etc.
}
In the Unity Editor, just fill in the fields:
Has this changed in 2018.1? The documentation still says we can pass a pram, but when I select the event, I only get a pulldown to select the available functions from my Class. Functions that accept any params will not show up at all (Or, if I add a param to a function I'm already calling, it leaves it in the pulldown as e.g: ExampleFunction() )