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.

58 Zeilen
1.4KB

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace coa4u
  5. {
  6. /// <summary>
  7. /// Scales the object by the given multiplier.
  8. /// </summary>
  9. class ActionScaleBy : ActionInterval
  10. {
  11. protected Vector3 delta;
  12. protected Vector3 path;
  13. public ActionScaleBy(Vector3 targetDelta, float targetDuration)
  14. : base(targetDuration)
  15. {
  16. delta = targetDelta;
  17. }
  18. public ActionScaleBy(Vector2 targetValue, float targetDuration)
  19. : this((Vector3)targetValue, targetDuration)
  20. {
  21. }
  22. public override ActionInstant Clone()
  23. {
  24. return new ActionScaleBy(delta, duration);
  25. }
  26. public override ActionInstant Reverse()
  27. {
  28. return new ActionScaleBy(delta * -1F, duration);
  29. }
  30. public override void Start()
  31. {
  32. base.Start();
  33. Vector3 scale = transform.localScale;
  34. scale.x *= delta.x;
  35. scale.y *= delta.y;
  36. scale.z *= delta.z;
  37. path = scale - transform.localScale;
  38. }
  39. public override void Step(float dt)
  40. {
  41. float d = dt / duration;
  42. Vector3 target = path * d;
  43. transform.localScale += target;
  44. }
  45. public override void Stop()
  46. {
  47. base.Stop();
  48. }
  49. }
  50. }