fix cancel handling

This commit is contained in:
Masataka SUMI 2022-02-09 20:33:49 +09:00
parent a6945d79f9
commit a22b4b6f52

View File

@ -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();