Skip to content

Commit e4e661e

Browse files
authored
BugFix: WithOnLoopComplete When bool skipValuesDuringDelay = true
FixBug At ,Once SkipValuesDuringDelay is ture, it will not just skip UpdateUnsafe , but also InvokeOnLoopComplete And InvokeOnComplete ,
1 parent 1d170af commit e4e661e

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

src/LitMotion/Assets/LitMotion/Runtime/Internal/UpdateRunner.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,13 @@ public unsafe void Update(double time, double unscaledTime, double realtime)
7373

7474
var status = state.Status;
7575
ref var managedData = ref managedDataSpan[i];
76-
if (status is MotionStatus.Playing or MotionStatus.Completed || (status == MotionStatus.Delayed && !managedData.SkipValuesDuringDelay))
76+
77+
bool isPlaying = status == MotionStatus.Playing;
78+
bool isCompleted = status == MotionStatus.Completed;
79+
bool isDelayed = status == MotionStatus.Delayed;
80+
bool canUpdate = isPlaying || isCompleted || (isDelayed && !managedData.SkipValuesDuringDelay);
81+
bool loopComplete = (isPlaying || isCompleted || isDelayed) && state.WasLoopCompleted;
82+
if (canUpdate)
7783
{
7884
try
7985
{
@@ -88,17 +94,9 @@ public unsafe void Update(double time, double unscaledTime, double realtime)
8894
managedData.OnCancelAction?.Invoke();
8995
}
9096
}
91-
92-
if (state.WasLoopCompleted)
93-
{
94-
managedData.InvokeOnLoopComplete(state.CompletedLoops);
95-
}
96-
97-
if (status is MotionStatus.Completed && state.WasStatusChanged)
98-
{
99-
managedData.InvokeOnComplete();
100-
}
10197
}
98+
if (loopComplete) managedData.InvokeOnLoopComplete(state.CompletedLoops);
99+
if (isCompleted && state.WasStatusChanged) managedData.InvokeOnComplete();
102100
}
103101
}
104102

@@ -113,4 +111,4 @@ public void Reset()
113111
storage.Reset();
114112
}
115113
}
116-
}
114+
}

0 commit comments

Comments
 (0)