RawImageAnimationMixer.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using UnityEngine.UI;
  2. namespace UnityUIPlayables
  3. {
  4. public class RawImageAnimationMixer : AnimationMixer<RawImage, RawImageAnimationBehaviour>
  5. {
  6. private readonly GraphicColorMixer _colorMixer = new GraphicColorMixer();
  7. private readonly RawImageUVRectMixer _uvRectMixer = new RawImageUVRectMixer();
  8. public override void SetupFrame(RawImage binding)
  9. {
  10. base.SetupFrame(binding);
  11. _colorMixer.SetupFrame();
  12. _uvRectMixer.SetupFrame();
  13. }
  14. public override void Blend(RawImageAnimationBehaviour 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.ControlUvRect)
  21. {
  22. _uvRectMixer.Blend(behaviour.StartValue.UvRect, behaviour.EndValue.UvRect, inputWeight, progress);
  23. }
  24. }
  25. public override void ApplyFrame()
  26. {
  27. _colorMixer.ApplyFrame(Binding);
  28. _uvRectMixer.ApplyFrame(Binding);
  29. }
  30. }
  31. }