diff --git a/addons/GDTask/PlayerLoopTimer.cs b/addons/GDTask/PlayerLoopTimer.cs index a317225..4709201 100644 --- a/addons/GDTask/PlayerLoopTimer.cs +++ b/addons/GDTask/PlayerLoopTimer.cs @@ -142,6 +142,7 @@ bool IPlayerLoopItem.MoveNext() sealed class DeltaTimePlayerLoopTimer : PlayerLoopTimer { + bool isMainThread; ulong initialFrame; double elapsed; double interval; @@ -156,7 +157,7 @@ protected override bool MoveNextCore() { if (elapsed == 0.0) { - if (initialFrame == Engine.GetProcessFrames()) + if (isMainThread && initialFrame == Engine.GetProcessFrames()) { return true; } @@ -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;