AnimancerJob.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Animancer // https://kybernetik.com.au/animancer // Copyright 2022 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. /// <remarks>
  9. /// Documentation: <see href="https://kybernetik.com.au/animancer/docs/manual/ik#animated-properties">Animated Properties</see>
  10. /// </remarks>
  11. /// <example><see href="https://kybernetik.com.au/animancer/docs/examples/jobs">Animation Jobs</see></example>
  12. /// https://kybernetik.com.au/animancer/api/Animancer/AnimancerJob_1
  13. ///
  14. public abstract class AnimancerJob<T> where T : struct, IAnimationJob
  15. {
  16. /************************************************************************************************************************/
  17. /// <summary>The <see cref="IAnimationJob"/>.</summary>
  18. protected T _Job;
  19. /// <summary>The <see cref="AnimationScriptPlayable"/> running the job.</summary>
  20. protected AnimationScriptPlayable _Playable;
  21. /************************************************************************************************************************/
  22. /// <summary>Creates the <see cref="_Playable"/> and inserts it between the root and the graph output.</summary>
  23. protected void CreatePlayable(AnimancerPlayable animancer)
  24. {
  25. _Playable = animancer.InsertOutputJob(_Job);
  26. }
  27. /************************************************************************************************************************/
  28. /// <summary>
  29. /// Destroys the <see cref="_Playable"/> and restores the graph connection it was intercepting.
  30. /// </summary>
  31. /// <remarks>
  32. /// This method is NOT called automatically, so if you need to guarantee that things will get cleaned up you
  33. /// should use <see cref="AnimancerPlayable.Disposables"/>.
  34. /// </remarks>
  35. public virtual void Destroy()
  36. {
  37. AnimancerUtilities.RemovePlayable(_Playable);
  38. }
  39. /************************************************************************************************************************/
  40. }
  41. }