25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
Bu depo arşivlendi. Dosyaları görüntüleyebilir ve klonlayabilirsiniz ama işlem gönderemez ve konu/değişiklik isteği açamazsınız.

49 satır
1.3KB

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. class ActionTintTo : ActionInterval
  5. {
  6. public Vector4 color;
  7. public 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 = target.gameObject.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 = target.gameObject.renderer.material.color;
  37. tgtColor[0] += tgt[0];
  38. tgtColor[1] += tgt[1];
  39. tgtColor[2] += tgt[2];
  40. tgtColor[3] += tgt[3];
  41. target.gameObject.renderer.material.color = tgtColor;
  42. }
  43. }