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

ActionTintBy.cs 1.0KB

10年前
10年前
10年前
10年前
10年前
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. }