using System; using UnityEngine.Events; namespace UnityEngine.XR.Content.Animation { /// /// Will receive triggers from the and classes, /// and forward them to Unity Events. /// public class OnAnimationEvent : MonoBehaviour, IAnimationEventActionBegin, IAnimationEventActionFinished { [Serializable] struct ActionEvent { public string m_Label; public UnityEvent m_Action; } [SerializeField] ActionEvent[] m_ActionBeginEvents; [SerializeField] ActionEvent[] m_ActionEndEvents; /// public void ActionBegin(string label) { if (m_ActionBeginEvents == null) return; foreach (var currentAction in m_ActionBeginEvents) { if (currentAction.m_Label == label) currentAction.m_Action.Invoke(); } } /// public void ActionFinished(string label) { if (m_ActionEndEvents == null) return; foreach (var currentAction in m_ActionEndEvents) { if (currentAction.m_Label == label) currentAction.m_Action.Invoke(); } } } }