- Home /
Animation Event won't show the function I need
I'm trying to add a function to fire on a certain frame, but the function I need will not show up in the edit animation event window. How do I fix this?
Answer by GearKlik · Mar 21, 2018 at 09:17 PM
Old question but I worked this out, if you select an animation clip in the Project explorer and try and edit an event's properties it wont show a list of available functions.
However If you select an object in your scene graph with an Animator component then bring the Animation window and select your clip in the dropdown it will show a list of functions you can call. It makes sense because Unity won't know which functions it can call just by editing the animation clip asset, it needs the context of the game object that's playing it.
Thanks.
This is one of those things that if you don't do often, even if you know it, you may forget.
I'm really glad you posted your answer!
Answer by JCX · Jan 24, 2014 at 07:49 PM
animation event calls public methods of other components attached to gameObject playing the animation
so basically make component (monobehaviour class) AnimationEventListener and make public method like
public void EventHandlerMethod()
{
// the code you need
}
attach it to the gameObject in scene and it should appear in the dropdown menu of AnimationEvent keyframe
Ok, but the animation event window only shows functions from the parent gameobject. How do I make it show the functions of the child gameobjects?
i'm not sure you can do that, but for sure you can call them from the parent component
http://docs.unity3d.com/Documentation/ScriptReference/Component.GetComponentInChildren.html
Answer by kentmw · Nov 07, 2016 at 10:37 PM
Check out this answer: http://answers.unity3d.com/questions/786404/why-dont-animation-events-allow-you-to-call-functi.html
If you have a boolean parameter, it doesn't show
Answer by Danief_ · Nov 15, 2019 at 03:00 AM
For anybody else who lands here, the animator can only call methods with a single parameter. If you have several parameters, it won't appear on the list. You have to pass a parameter of type AnimationEvent
. Here are more details: https://answers.unity.com/questions/11159/one-parameter-limit-on-animation-event-functions-t.html
Answer by SamuelKeller · Jan 08 at 07:39 PM
Old question, but another issue that might cause this is attaching the script to a child of the object holding the animator, the script must be attached to the parent object for the function to show.
Your answer
Follow this Question
Related Questions
Is there any way to call OnLevelLoaded when loading a scene in editor? 2 Answers
Animation Event - "Function not supported" 2 Answers
Better way to call function from another script from editor script? 1 Answer
Changes in variables from function triggered by editor script during edit mode are not applied. 2 Answers
Using draggable actions in Editor 0 Answers