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.

ActionTintBy.cs 1.0KB

10 vuotta sitten
10 vuotta sitten
10 vuotta sitten
10 vuotta sitten
10 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. class ActionTintBy : ActionInterval
  5. {
  6. protected Vector4 color;
  7. protected const float coeff = 1F / 255F;
  8. public ActionTintBy(Vector4 tgtColor, float tgtDuration)
  9. : base(tgtDuration)
  10. {
  11. color = tgtColor * coeff;
  12. }
  13. public ActionTintBy(Vector3 tgtColor, float tgtDuration)
  14. : this(new Vector4(tgtColor.x, tgtColor.y, tgtColor.z), tgtDuration)
  15. {
  16. }
  17. public override Action clone()
  18. {
  19. return new ActionTintBy(color / coeff, duration);
  20. }
  21. public override Action reverse()
  22. {
  23. return new ActionTintBy(-color / coeff, duration);
  24. }
  25. public override void stepInterval(float dt)
  26. {
  27. float d = dt / duration;
  28. Vector4 tgt = color * d;
  29. Color tgtColor = renderer.material.color;
  30. tgtColor[0] += tgt[0];
  31. tgtColor[1] += tgt[1];
  32. tgtColor[2] += tgt[2];
  33. tgtColor[3] += tgt[3];
  34. renderer.material.color = tgtColor;
  35. }
  36. }