I’m trying to assign objectReferenceParameter to the gameObject that owns the script with the target function that I want to fire from the AnimationEvent.
private void AssignAnimationEvents()
{
AnimationClip[] clips = mAnimator.runtimeAnimatorController.animationClips;
for (int i = 0; i < clips.Length; ++i)
{
AnimationClip clip = mAnimator.runtimeAnimatorController.animationClips[i];
AnimationEvent[] events = clip.events;
for (int j = 0; j < events.Length; ++j)
{
AnimationEvent animEvt = clip.events[j];
if (animEvt != null)
{
animEvt.objectReferenceParameter = gameObject;
string funcName = animEvt.functionName;
// TODO: Use some reflection to assert function existence
}
}
}
mAnimator.Rebind();
}
public void End_Die()
{
Dbg.Log("End Die!!!!");
}
However, after calling Rebind(), the function End_Die() still doesn’t fire. Is there something I’m missing here?