SimpleAnimationPlayerAnimationClipMapper.cs 1.2 KB

1234567891011121314151617181920212223
  1. using TriLibCore.General;
  2. using TriLibCore.Playables;
  3. using UnityEngine;
  4. namespace TriLibCore.Mappers
  5. {
  6. /// <summary>Represents a Mapper that creates a Simple Animation Player used to play Animation Clips by their index or name.</summary>
  7. [CreateAssetMenu(menuName = "TriLib/Mappers/Animation Clip/Simple Animation Player Animation Clip Mapper", fileName = "SimpleAnimationPlayerAnimationClipMapper")]
  8. public class SimpleAnimationPlayerAnimationClipMapper : AnimationClipMapper
  9. {
  10. ///<inheritdoc />
  11. public override AnimationClip[] MapArray(AssetLoaderContext assetLoaderContext, AnimationClip[] sourceAnimationClips)
  12. {
  13. if ((assetLoaderContext.Options.AnimationType == AnimationType.Generic || assetLoaderContext.Options.AnimationType == AnimationType.Humanoid) && sourceAnimationClips.Length > 0)
  14. {
  15. var simpleAnimationPlayer = assetLoaderContext.RootGameObject.AddComponent<SimpleAnimationPlayer>();
  16. simpleAnimationPlayer.AnimationClips = sourceAnimationClips;
  17. simpleAnimationPlayer.enabled = false;
  18. }
  19. return sourceAnimationClips;
  20. }
  21. }
  22. }