diff --git a/Assets/VRMShaders/GLTF/IO/Runtime/AwaitCaller/TinyManagedTaskScheduler.cs b/Assets/VRMShaders/GLTF/IO/Runtime/AwaitCaller/TinyManagedTaskScheduler.cs index 2f96cc5ef..e6fc0c5ee 100644 --- a/Assets/VRMShaders/GLTF/IO/Runtime/AwaitCaller/TinyManagedTaskScheduler.cs +++ b/Assets/VRMShaders/GLTF/IO/Runtime/AwaitCaller/TinyManagedTaskScheduler.cs @@ -9,6 +9,8 @@ namespace VRMShaders { private readonly ConcurrentQueue<(Action, Func)> _continuationQueue = new ConcurrentQueue<(Action, Func)>(); + private readonly ConcurrentQueue<(Action, Func)> _temporaryQueue = + new ConcurrentQueue<(Action, Func)>(); public void ManagedUpdate() { @@ -22,9 +24,14 @@ namespace VRMShaders } else { - _continuationQueue.Enqueue(tuple); + _temporaryQueue.Enqueue(tuple); } } + + while (_temporaryQueue.TryDequeue(out var tuple)) + { + _continuationQueue.Enqueue(tuple); + } } public void Enqueue(Action continuation, Func canExecute)