AnimancerJob.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2024 Kybernetik //
  2. using UnityEngine.Animations;
  3. namespace Animancer
  4. {
  5. /// <summary>[Pro-Only]
  6. /// A base class that allows Animation Jobs to be easily inserted into an Animancer graph.
  7. /// </summary>
  8. ///
  9. /// <remarks>
  10. /// <strong>Documentation:</strong>
  11. /// <see href="https://kybernetik.com.au/animancer/docs/manual/ik#animated-properties">
  12. /// Animated Properties</see>
  13. /// </remarks>
  14. ///
  15. /// https://kybernetik.com.au/animancer/api/Animancer/AnimancerJob_1
  16. ///
  17. public abstract class AnimancerJob<T> where T : struct, IAnimationJob
  18. {
  19. /************************************************************************************************************************/
  20. /// <summary>The <see cref="IAnimationJob"/>.</summary>
  21. protected T _Job;
  22. /// <summary>The <see cref="AnimationScriptPlayable"/> running the job.</summary>
  23. protected AnimationScriptPlayable _Playable;
  24. /************************************************************************************************************************/
  25. /// <summary>Creates the <see cref="_Playable"/> and inserts it between the root and the graph output.</summary>
  26. protected void CreatePlayable(AnimancerGraph animancer)
  27. {
  28. _Playable = animancer.InsertOutputJob(_Job);
  29. }
  30. /************************************************************************************************************************/
  31. /// <summary>
  32. /// Destroys the <see cref="_Playable"/> and restores the graph connection it was intercepting.
  33. /// </summary>
  34. /// <remarks>
  35. /// This method is NOT called automatically, so if you need to guarantee that things will get cleaned up you
  36. /// should use <see cref="AnimancerGraph.Disposables"/>.
  37. /// </remarks>
  38. public virtual void Destroy()
  39. {
  40. AnimancerUtilities.RemovePlayable(_Playable);
  41. }
  42. /************************************************************************************************************************/
  43. }
  44. }