fix await caller. ハイレベルAPI で awaitCaller=null 引き数を受ける関数が、new ImmediateCaller する

This commit is contained in:
ousttrue
2022-02-24 19:15:59 +09:00
parent 7cb05f041d
commit 3c873cdbaa
2 changed files with 23 additions and 2 deletions

View File

@@ -44,6 +44,11 @@ namespace UniVRM10
VrmMetaInformationCallback vrmMetaInformationCallback = null,
CancellationToken ct = default)
{
if (awaitCaller == null)
{
awaitCaller = new ImmediateCaller();
}
return await LoadAsync(
path,
System.IO.File.ReadAllBytes(path),
@@ -81,6 +86,11 @@ namespace UniVRM10
VrmMetaInformationCallback vrmMetaInformationCallback = null,
CancellationToken ct = default)
{
if (awaitCaller == null)
{
awaitCaller = new ImmediateCaller();
}
return await LoadAsync(
string.Empty,
bytes,
@@ -105,7 +115,6 @@ namespace UniVRM10
CancellationToken ct)
{
ct.ThrowIfCancellationRequested();
if (awaitCaller == null)
{
throw new ArgumentNullException();
@@ -172,6 +181,10 @@ namespace UniVRM10
CancellationToken ct)
{
ct.ThrowIfCancellationRequested();
if (awaitCaller == null)
{
throw new ArgumentNullException();
}
var vrm10Data = await awaitCaller.Run(() => Vrm10Data.Parse(gltfData));
ct.ThrowIfCancellationRequested();
@@ -203,6 +216,10 @@ namespace UniVRM10
CancellationToken ct)
{
ct.ThrowIfCancellationRequested();
if (awaitCaller == null)
{
throw new ArgumentNullException();
}
Vrm10Data migratedVrm10Data = default;
MigrationData migrationData = default;
@@ -243,6 +260,10 @@ namespace UniVRM10
CancellationToken ct)
{
ct.ThrowIfCancellationRequested();
if (awaitCaller == null)
{
throw new ArgumentNullException();
}
if (vrm10Data == null)
{

View File

@@ -86,7 +86,7 @@ namespace UniVRM10.FirstPersonSample
async Task<Vrm10Instance> LoadAsync(string path, VRMShaders.IAwaitCaller awaitCaller)
{
var instance = await Vrm10.LoadPathAsync(path);
var instance = await Vrm10.LoadPathAsync(path, awaitCaller: awaitCaller);
// VR用 FirstPerson 設定
await instance.Vrm.FirstPerson.SetupAsync(instance.gameObject, awaitCaller);