ImageAnimationMixer.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using UnityEngine.UI;
  2. namespace UnityUIPlayables
  3. {
  4. public class ImageAnimationMixer : AnimationMixer<Image, ImageAnimationBehaviour>
  5. {
  6. private readonly GraphicColorMixer _colorMixer = new GraphicColorMixer();
  7. private readonly ImageFillAmountMixer _fillAmountMixer = new ImageFillAmountMixer();
  8. public override void SetupFrame(Image binding)
  9. {
  10. base.SetupFrame(binding);
  11. _colorMixer.SetupFrame();
  12. _fillAmountMixer.SetupFrame();
  13. }
  14. public override void Blend(ImageAnimationBehaviour behaviour, float inputWeight, float progress)
  15. {
  16. if (behaviour.ControlColor)
  17. {
  18. _colorMixer.Blend(behaviour.StartValue.Color, behaviour.EndValue.Color, inputWeight, progress);
  19. }
  20. if (behaviour.ControlFillAmount)
  21. {
  22. _fillAmountMixer.Blend(behaviour.StartValue.FillAmount, behaviour.EndValue.FillAmount, inputWeight,
  23. progress);
  24. }
  25. }
  26. public override void ApplyFrame()
  27. {
  28. _colorMixer.ApplyFrame(Binding);
  29. _fillAmountMixer.ApplyFrame(Binding);
  30. }
  31. }
  32. }