Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
Это архивный репозиторий. Вы можете его клонировать или просматривать файлы, но не вносить изменения или открывать задачи/запросы на слияние.

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