Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
Dieses Repo ist archiviert. Du kannst Dateien sehen und es klonen, kannst aber nicht pushen oder Issues/Pull-Requests öffnen.

ActionTintBy.cs 1.2KB

vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. }