PlayAnimationOnEnable.cs 1.7 KB

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