I have a GameObject with an Animator and some animations that can trigger an event (with a specific callback function).
As long as I add a Script to the same GameObject as the Animator, that includes the receiver, everything works fine:
public class AnimatorEventReceiver : MonoBehaviour {
void OnAnimationEnd( AnimationEvent animationEvent ) {
// do something
}
}
(it's a simplified example, I stripped anything unecessary)
My problem is: I have to listen for this event outside of the GameObject that contains the Animator. I have full access to the GameObject itself, how can I externally add an "EventListener" to listen for this AnimationEvent?
I'm kind of looking for the Unity/C# equivalent of a Javascript "object.addEventListener( callback )"
The object that should receive the AnimationEvent, is the parent of the GameObject containing the Animator - if that helps.

