AnimancerGraphSpeedSlider.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2024 Kybernetik //
  2. #if UNITY_EDITOR
  3. using UnityEngine;
  4. namespace Animancer.Editor
  5. {
  6. /// <summary>[Editor-Only]
  7. /// <see cref="ToggledSpeedSlider"/> for <see cref="AnimancerGraph"/>.
  8. /// </summary>
  9. /// https://kybernetik.com.au/animancer/api/Animancer.Editor/AnimancerGraphSpeedSlider
  10. public class AnimancerGraphSpeedSlider : ToggledSpeedSlider
  11. {
  12. /************************************************************************************************************************/
  13. /// <summary>Singleton.</summary>
  14. public static readonly AnimancerGraphSpeedSlider
  15. Instance = new();
  16. /// <summary>The target graph.</summary>
  17. public AnimancerGraph Graph { get; set; }
  18. /************************************************************************************************************************/
  19. /// <summary>Creates a new <see cref="AnimancerGraphSpeedSlider"/>.</summary>
  20. public AnimancerGraphSpeedSlider()
  21. : base(nameof(AnimancerGraphSpeedSlider) + ".Show")
  22. {
  23. }
  24. /************************************************************************************************************************/
  25. /// <inheritdoc/>
  26. protected override void OnSetSpeed(float speed)
  27. {
  28. if (Graph != null)
  29. Graph.Speed = speed;
  30. }
  31. /************************************************************************************************************************/
  32. /// <inheritdoc/>
  33. public override bool DoToggleGUI(Rect area, GUIStyle style)
  34. {
  35. if (Graph != null)
  36. Speed = Graph.Speed;
  37. return base.DoToggleGUI(area, style);
  38. }
  39. /************************************************************************************************************************/
  40. }
  41. }
  42. #endif