Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
Repozitorijs ir arhivēts. Tam var aplūkot failus un to var klonēt, bet nevar iesūtīt jaunas izmaiņas, kā arī atvērt jaunas problēmas/izmaiņu pieprasījumus.

52 rindas
1.4KB

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace coa4u
  5. {
  6. class ActionTintTo : ActionInterval
  7. {
  8. protected Vector4 color;
  9. protected Vector4 path;
  10. protected const float coeff = 1F / 255F;
  11. public ActionTintTo(Vector4 tgtColor, float tgtDuration)
  12. : base(tgtDuration)
  13. {
  14. color = tgtColor * coeff;
  15. path = Vector4.zero;
  16. }
  17. public ActionTintTo(Vector3 tgtColor, float tgtDuration)
  18. : this(new Vector4(tgtColor.x, tgtColor.y, tgtColor.z), tgtDuration)
  19. {
  20. }
  21. public override ActionInstant clone()
  22. {
  23. return new ActionTintTo(color / coeff, duration);
  24. }
  25. public override void start()
  26. {
  27. base.start();
  28. Color tgtColor = renderer.material.color;
  29. path[0] = color[0] - tgtColor[0];
  30. path[1] = color[1] - tgtColor[1];
  31. path[2] = color[2] - tgtColor[2];
  32. path[3] = color[3] - tgtColor[3];
  33. }
  34. public override void stepInterval(float dt)
  35. {
  36. float d = dt / duration;
  37. Vector4 tgt = path * d;
  38. Color tgtColor = renderer.material.color;
  39. tgtColor[0] += tgt[0];
  40. tgtColor[1] += tgt[1];
  41. tgtColor[2] += tgt[2];
  42. tgtColor[3] += tgt[3];
  43. renderer.material.color = tgtColor;
  44. }
  45. }
  46. }