Skip to content

Commit

Permalink
Update Player Loop TImer
Browse files Browse the repository at this point in the history
  • Loading branch information
Delsin-Yu committed Dec 30, 2023
1 parent 7306619 commit 75ccc87
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions addons/GDTask/PlayerLoopTimer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ bool IPlayerLoopItem.MoveNext()

sealed class DeltaTimePlayerLoopTimer : PlayerLoopTimer
{
bool isMainThread;
ulong initialFrame;
double elapsed;
double interval;
Expand All @@ -156,7 +157,7 @@ protected override bool MoveNextCore()
{
if (elapsed == 0.0)
{
if (initialFrame == Engine.GetProcessFrames())
if (isMainThread && initialFrame == Engine.GetProcessFrames())
{
return true;
}
Expand All @@ -174,7 +175,8 @@ protected override bool MoveNextCore()
protected override void ResetCore(TimeSpan? interval)
{
this.elapsed = 0.0;
this.initialFrame = GDTaskPlayerLoopAutoload.IsMainThread ? Engine.GetProcessFrames() : 0ul;
this.isMainThread = GDTaskPlayerLoopAutoload.IsMainThread;
this.initialFrame = Engine.GetProcessFrames();
if (interval != null)
{
this.interval = (float)interval.Value.TotalSeconds;
Expand Down

0 comments on commit 75ccc87

Please sign in to comment.