/// <summary> /// Responds to the received animation event /// </summary> /// <param name="EventLabel">The label used to describe the received event</param> /// <param name="args">Arguments related to the animation event</param> public void ReceiveEvent(string EventLabel, StateMachineEventArgs args) { if (eventDictionary.TryGetValue(EventLabel, out UnityEvent eventToFire)) { eventToFire.Invoke(); } }
/// <summary> /// Intended for children to call to notify the scene of animation-specific events /// </summary> /// <param name="Anim">The animator to fire the events in relation to</param> protected virtual void FireEvents(Animator animator, AnimatorStateInfo stateInfo, int layerIndex, AnimatorControllerPlayable controller) { IEnumerable <IAnimationEventListener> animEvents = GetEventReceivers(animator); StateMachineEventArgs args = new StateMachineEventArgs(animator, stateInfo, layerIndex, controller); int numNotified = 0; foreach (StringReference eventToFire in EventsToFire) { foreach (IAnimationEventListener animEvent in animEvents) { animEvent.ReceiveEvent(eventToFire, args); numNotified++; } } if (numNotified == 0) { Debug.LogError("No AnimationEventReceivers found on: " + animator.name, this); } }