選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
このリポジトリはアーカイブされています。 ファイルの閲覧とクローンは可能ですが、プッシュや、課題・プルリクエストのオープンはできません。

45 行
1.2KB

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