Skip to content

Commit 6e727cd

Browse files
committed
Fixed null reference exception.
CurrentValue is set to default upon initialisation of tween update.
1 parent 017d63a commit 6e727cd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Runtime/Tween.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static Tween Create<T>(T start, T end, float duration, LerpFunction<T> le
9191
LerpFunction = (a, b, t) => lerpFunction((T)a, (T)b, t),
9292
EasingFunction = easingFunction,
9393
UnderlyingType = typeof(T),
94-
_onUpdate = x => onUpdate((T)x),
94+
_onUpdate = x => onUpdate?.Invoke((T)x),
9595
_onComplete = onComplete
9696
};
9797

@@ -369,6 +369,7 @@ private IEnumerator Update()
369369
IsActive = true;
370370
IsPaused = false;
371371
ElapsedTime = 0.0f;
372+
CurrentValue = default;
372373

373374
// Wait until the end of the frame before starting
374375
yield return new WaitForEndOfFrame();

0 commit comments

Comments
 (0)