You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

34 lines
729B

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. class ActionFadeTo : ActionInterval
  5. {
  6. protected float value;
  7. protected float delta;
  8. public ActionFadeTo(float tgtValue, float tgtDuration)
  9. : base(tgtDuration)
  10. {
  11. value = tgtValue;
  12. }
  13. public override Action clone()
  14. {
  15. return new ActionFadeTo(value, duration);
  16. }
  17. public override void start()
  18. {
  19. base.start();
  20. delta = value - renderer.material.color.a;
  21. }
  22. public override void stepInterval(float dt)
  23. {
  24. float d = dt / duration;
  25. Color tgtColor = renderer.material.color;
  26. tgtColor[3] += delta * d;
  27. renderer.material.color = tgtColor;
  28. }
  29. }