// Animancer // https://kybernetik.com.au/animancer // Copyright 2021 Kybernetik // #pragma warning disable CS0649 // Field is never assigned to, and will always have its default value. using UnityEngine; namespace Animancer.Examples.Events { /// A that uses Animation Events. /// Golf Events /// https://kybernetik.com.au/animancer/api/Animancer.Examples.Events/GolfHitControllerAnimation /// [AddComponentMenu(Strings.ExamplesMenuPrefix + "Golf Events - Animation")] [HelpURL(Strings.DocsURLs.ExampleAPIDocumentation + nameof(Events) + "/" + nameof(GolfHitControllerAnimation))] public sealed class GolfHitControllerAnimation : GolfHitController { /************************************************************************************************************************/ /// /// Calls the base method and register /// to be called whenever the swing animation ends. /// /// Normally Animancer could call the registered method at the End Time defined in the transition, but in this /// case the used with this script has an Animation Event with the Function Name /// "End", which will execute the registered method when that event time passes. /// protected override void Awake() { base.Awake(); _Swing.Events.OnEnd = EndSwing; } /************************************************************************************************************************/ /// /// Calls . The used with this script has an /// Animation Event with the Function Name "Event", which will cause it to execute this method. /// /// Normally you would just have the event use "HitBall" as its Function Name directly, but the same animation /// is also being used for which relies on the Function Name /// being "Event". /// private void Event() { HitBall(); } /************************************************************************************************************************/ /// Calls . /// /// Called by Animation Events with the Function Name "End". /// /// Note that Unity will allocate some garbage every time it triggers an Animation Event with an /// parameter. /// private void End(AnimationEvent animationEvent) { EndEventReceiver.End(_Animancer, animationEvent); } /************************************************************************************************************************/ } }