From 3c873cdbaa7fcf8483e24918cf9a2236ae781890 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 24 Feb 2022 19:15:59 +0900 Subject: [PATCH] =?UTF-8?q?fix=20await=20caller.=20=E3=83=8F=E3=82=A4?= =?UTF-8?q?=E3=83=AC=E3=83=99=E3=83=ABAPI=20=E3=81=A7=20awaitCaller=3Dnull?= =?UTF-8?q?=20=E5=BC=95=E3=81=8D=E6=95=B0=E3=82=92=E5=8F=97=E3=81=91?= =?UTF-8?q?=E3=82=8B=E9=96=A2=E6=95=B0=E3=81=8C=E3=80=81new=20ImmediateCal?= =?UTF-8?q?ler=20=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/VRM10/Runtime/IO/Vrm10.cs | 23 ++++++++++++++++++- .../VRM10RuntimeLoader.cs | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Assets/VRM10/Runtime/IO/Vrm10.cs b/Assets/VRM10/Runtime/IO/Vrm10.cs index daf3b51c6..c28e25e0b 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10.cs @@ -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) { diff --git a/Assets/VRM10_Samples/VRM10FirstPersonSample/VRM10RuntimeLoader.cs b/Assets/VRM10_Samples/VRM10FirstPersonSample/VRM10RuntimeLoader.cs index bcd5fd278..3a0feb381 100644 --- a/Assets/VRM10_Samples/VRM10FirstPersonSample/VRM10RuntimeLoader.cs +++ b/Assets/VRM10_Samples/VRM10FirstPersonSample/VRM10RuntimeLoader.cs @@ -86,7 +86,7 @@ namespace UniVRM10.FirstPersonSample async Task 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);