diff --git a/Assets/VRMShaders/GLTF/IO/Runtime/AwaitCaller/IAwaitCaller.cs b/Assets/VRMShaders/GLTF/IO/Runtime/AwaitCaller/IAwaitCaller.cs
index c97e4d0ce..877ae8ae0 100644
--- a/Assets/VRMShaders/GLTF/IO/Runtime/AwaitCaller/IAwaitCaller.cs
+++ b/Assets/VRMShaders/GLTF/IO/Runtime/AwaitCaller/IAwaitCaller.cs
@@ -31,5 +31,11 @@ namespace VRMShaders
///
///
Task Run(Func action);
+
+ ///
+ /// 指定した時間が経過している場合のみ、NextFrame() を使って1フレーム待つ
+ ///
+ /// タイムアウト時はNextFrame()を呼び出す。そうではない場合、Task.CompletedTaskを返す
+ Task NextFrameIfTimedOut();
}
}
diff --git a/Assets/VRMShaders/GLTF/IO/Runtime/AwaitCaller/ImmediateCaller.cs b/Assets/VRMShaders/GLTF/IO/Runtime/AwaitCaller/ImmediateCaller.cs
index f3e6d56a0..db71fe818 100644
--- a/Assets/VRMShaders/GLTF/IO/Runtime/AwaitCaller/ImmediateCaller.cs
+++ b/Assets/VRMShaders/GLTF/IO/Runtime/AwaitCaller/ImmediateCaller.cs
@@ -23,5 +23,7 @@ namespace VRMShaders
{
return Task.FromResult(action());
}
+
+ public Task NextFrameIfTimedOut() => NextFrame();
}
}
\ No newline at end of file
diff --git a/Assets/VRMShaders/GLTF/IO/Runtime/AwaitCaller/RuntimeOnlyAwaitCaller.cs b/Assets/VRMShaders/GLTF/IO/Runtime/AwaitCaller/RuntimeOnlyAwaitCaller.cs
index 83665d7a0..b583465ff 100644
--- a/Assets/VRMShaders/GLTF/IO/Runtime/AwaitCaller/RuntimeOnlyAwaitCaller.cs
+++ b/Assets/VRMShaders/GLTF/IO/Runtime/AwaitCaller/RuntimeOnlyAwaitCaller.cs
@@ -10,14 +10,23 @@ namespace VRMShaders
public sealed class RuntimeOnlyAwaitCaller : IAwaitCaller
{
private readonly NextFrameTaskScheduler _scheduler;
+ private readonly float _timeOutInSeconds;
+ private float _lastTimeoutBaseTime;
- public RuntimeOnlyAwaitCaller()
+ ///
+ /// タイムアウト指定可能なコンストラクタ
+ ///
+ /// NextFrameIfTimedOutがタイムアウトと見なす時間(秒単位)
+ public RuntimeOnlyAwaitCaller(float timeOutInSeconds = 1f / 1000f)
{
_scheduler = new NextFrameTaskScheduler();
+ _timeOutInSeconds = timeOutInSeconds;
+ ResetLastTimeoutBaseTime();
}
public Task NextFrame()
{
+ ResetLastTimeoutBaseTime();
var tcs = new TaskCompletionSource