LinearBlendTreeLocomotion.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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.Locomotion
  5. {
  6. /// <summary>
  7. /// An example of how you can wrap a <see cref="RuntimeAnimatorController"/> containing a single blend tree in a
  8. /// <see cref="Float1ControllerState"/> to easily control its parameter.
  9. /// </summary>
  10. /// <example><see href="https://kybernetik.com.au/animancer/docs/examples/locomotion/linear-blending">Linear Blending</see></example>
  11. /// https://kybernetik.com.au/animancer/api/Animancer.Examples.Locomotion/LinearBlendTreeLocomotion
  12. ///
  13. [AddComponentMenu(Strings.ExamplesMenuPrefix + "Locomotion - Linear Blend Tree Locomotion")]
  14. [HelpURL(Strings.DocsURLs.ExampleAPIDocumentation + nameof(Locomotion) + "/" + nameof(LinearBlendTreeLocomotion))]
  15. public sealed class LinearBlendTreeLocomotion : MonoBehaviour
  16. {
  17. /************************************************************************************************************************/
  18. [SerializeField] private AnimancerComponent _Animancer;
  19. [SerializeField] private Float1ControllerTransitionAsset.UnShared _Controller;
  20. /************************************************************************************************************************/
  21. private void OnEnable()
  22. {
  23. _Animancer.Play(_Controller);
  24. }
  25. /************************************************************************************************************************/
  26. /// <summary>Controlled by a <see cref="UnityEngine.UI.Slider"/>.</summary>
  27. public float Speed
  28. {
  29. get => _Controller.State.Parameter;
  30. set => _Controller.State.Parameter = value;
  31. }
  32. /************************************************************************************************************************/
  33. }
  34. }