Skip to content

Commit

Permalink
Add an option to use Time.unscaledTime
Browse files Browse the repository at this point in the history
  • Loading branch information
inact1v1ty authored Apr 27, 2024
1 parent 9e74d4e commit 5506f85
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Runtime/Tween.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public abstract class Tween<T> : Tween

public float time = 1;

public bool unscaledTime;

public bool deltaMode;

public AnimationCurve animationCurve = AnimationCurve.EaseInOut(0, 0, 1, 1);
Expand Down Expand Up @@ -83,7 +85,8 @@ private void Update() {
return;
}

var t = (Time.time - startTime) / (endTime - startTime);
var currentTime = unscaledTime ? Time.unscaledTime : Time.time;
var t = (currentTime - startTime) / (endTime - startTime);
if (t >= 1) {
done = true;
}
Expand Down Expand Up @@ -118,7 +121,8 @@ public void SetValue(T newValue, bool instant = false, float delay = 0f) {
}

startValue = deltaMode ? this.Sub(accessor.Value, initialValue) : accessor.Value;
startTime = Time.time + delay;
var currentTime = unscaledTime ? Time.unscaledTime : Time.time;
startTime = currentTime + delay;

endValue = newValue;

Expand Down

0 comments on commit 5506f85

Please sign in to comment.