PlayAnimationOnEnable.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Animancer // https://kybernetik.com.au/animancer // Copyright 2022 Kybernetik //
  2. #pragma warning disable CS0649 // Field is never assigned to, and will always have its default value.
  3. using UnityEngine;
  4. namespace Animancer.Examples.Basics
  5. {
  6. /// <summary>Plays an animation to demonstrate the basic usage of Animancer.</summary>
  7. /// <remarks>
  8. /// If you actually want to only play one animation on an object and don't need any of the other features of
  9. /// Animancer, you can use the <see cref="SoloAnimation"/> component to do so without needing an extra script.
  10. /// </remarks>
  11. /// <example><see href="https://kybernetik.com.au/animancer/docs/examples/basics/quick-play">Quick Play</see></example>
  12. /// https://kybernetik.com.au/animancer/api/Animancer.Examples.Basics/PlayAnimationOnEnable
  13. ///
  14. [AddComponentMenu(Strings.ExamplesMenuPrefix + "Basics - Play Animation On Enable")]
  15. [HelpURL(Strings.DocsURLs.ExampleAPIDocumentation + nameof(Basics) + "/" + nameof(PlayAnimationOnEnable))]
  16. public sealed class PlayAnimationOnEnable : MonoBehaviour
  17. {
  18. /************************************************************************************************************************/
  19. [SerializeField] private AnimancerComponent _Animancer;
  20. [SerializeField] private AnimationClip _Animation;
  21. /************************************************************************************************************************/
  22. private void OnEnable()
  23. {
  24. _Animancer.Play(_Animation);
  25. }
  26. /************************************************************************************************************************/
  27. }
  28. }