diff --git a/Assets/VRM10/Runtime/IO/Vrm10.cs b/Assets/VRM10/Runtime/IO/Vrm10.cs index d92abced5..e9bb6028f 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10.cs @@ -157,14 +157,7 @@ namespace UniVRM10 { if (ct.IsCancellationRequested && result != null) { - if (Application.isPlaying) - { - UnityEngine.Object.Destroy(result.gameObject); - } - else - { - UnityEngine.Object.DestroyImmediate(result.gameObject); - } + UnityObjectDestoyer.DestroyRuntimeOrEditor(result.gameObject); } } } @@ -202,9 +195,8 @@ namespace UniVRM10 // 2. Load var gltfInstance = await loader.LoadAsync(awaitCaller); - if (ct.IsCancellationRequested) + if (gltfInstance == null) { - gltfInstance.Dispose(); return default; } @@ -215,6 +207,13 @@ namespace UniVRM10 return default; } + if (ct.IsCancellationRequested) + { + // NOTE: Destroy before showing meshes if cancelled. + gltfInstance.Dispose(); + return default; + } + if (showMeshes) { gltfInstance.ShowMeshes();