您最多选择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. }