DummyAnimancerComponent.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2024 Kybernetik //
  2. #if UNITY_EDITOR
  3. using UnityEngine;
  4. namespace Animancer.Editor.Previews
  5. {
  6. /// <summary>[Editor-Only]
  7. /// An <see cref="IAnimancerComponent"/> which isn't actually a <see cref="Component"/>.
  8. /// </summary>
  9. /// https://kybernetik.com.au/animancer/api/Animancer.Editor.Previews/DummyAnimancerComponent
  10. public class DummyAnimancerComponent : IAnimancerComponent
  11. {
  12. /************************************************************************************************************************/
  13. /// <summary>Creates a new <see cref="DummyAnimancerComponent"/>.</summary>
  14. public DummyAnimancerComponent(Animator animator, AnimancerGraph playable)
  15. {
  16. Animator = animator;
  17. Graph = playable;
  18. InitialUpdateMode = animator.updateMode;
  19. }
  20. /************************************************************************************************************************/
  21. /// <inheritdoc/>
  22. public bool enabled => true;
  23. /// <inheritdoc/>
  24. public GameObject gameObject => Animator.gameObject;
  25. /// <inheritdoc/>
  26. public Animator Animator { get; set; }
  27. /// <inheritdoc/>
  28. public AnimancerGraph Graph { get; private set; }
  29. /// <inheritdoc/>
  30. public bool IsGraphInitialized => true;
  31. /// <inheritdoc/>
  32. public bool ResetOnDisable => false;
  33. /// <inheritdoc/>
  34. public AnimatorUpdateMode UpdateMode
  35. {
  36. get => Animator.updateMode;
  37. set => Animator.updateMode = value;
  38. }
  39. /************************************************************************************************************************/
  40. /// <inheritdoc/>
  41. public object GetKey(AnimationClip clip) => clip;
  42. /************************************************************************************************************************/
  43. /// <inheritdoc/>
  44. public string AnimatorFieldName => null;
  45. /// <inheritdoc/>
  46. public string ActionOnDisableFieldName => null;
  47. /// <inheritdoc/>
  48. public AnimatorUpdateMode? InitialUpdateMode { get; private set; }
  49. /************************************************************************************************************************/
  50. /// <summary>Describes this and the <see cref="Animator"/>.</summary>
  51. public override string ToString()
  52. => $"{nameof(DummyAnimancerComponent)}({(Animator != null ? Animator.name : "Destroyed")})";
  53. /************************************************************************************************************************/
  54. }
  55. }
  56. #endif