// Animancer // Copyright 2020 Kybernetik //
using UnityEngine;
namespace Animancer
{
///
/// A component which uses Animation Events with the Function Name "Event" to trigger a callback.
///
/// This component must always be attached to the same as the in
/// order to receive Animation Events from it.
///
[AddComponentMenu(Strings.MenuPrefix + "Simple Event Receiver")]
[HelpURL(Strings.APIDocumentationURL + "/SimpleEventReceiver")]
public class SimpleEventReceiver : MonoBehaviour
{
/************************************************************************************************************************/
/// A callback for Animation Events with the Function Name "Event".
///
/// This field must be public instead of being wrapped in a property since
/// is a struct. Otherwise another class calling receiver.onEvent.Set(...) would actually get a copy of
/// the onEvent, set the desired values on that copy, and then immediately discard the copy without
/// actually modifying the underlying field.
///
public AnimationEventReceiver onEvent;
/// Called by Animation Events with the Function Name "Event".
private void Event(AnimationEvent animationEvent)
{
onEvent.SetFunctionName("Event");// The name of this method.
onEvent.HandleEvent(animationEvent);
}
/************************************************************************************************************************/
}
}