From 6421ffb4264685f6d5b7e2da1d8afeab01b371bd Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Wed, 9 Feb 2022 23:17:32 +0900 Subject: [PATCH] fix cancel bug --- Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs b/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs index 08179c76b..c614b5ac4 100644 --- a/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs +++ b/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs @@ -432,6 +432,7 @@ namespace UniVRM10.VRM10Viewer _cancellationTokenSource?.Dispose(); _cancellationTokenSource = new CancellationTokenSource(); + var cancellationToken = _cancellationTokenSource.Token; try { @@ -443,10 +444,10 @@ namespace UniVRM10.VRM10Viewer awaitCaller: new RuntimeOnlyAwaitCaller(), materialGenerator: GetVrmMaterialDescriptorGenerator(m_useUrpMaterial.isOn), vrmMetaInformationCallback: m_texts.UpdateMeta, - ct: _cancellationTokenSource.Token); + ct: cancellationToken); if (vrm10Instance != null) { - if (_cancellationTokenSource.Token.IsCancellationRequested) + if (cancellationToken.IsCancellationRequested) { UnityObjectDestoyer.DestroyRuntimeOrEditor(vrm10Instance.gameObject); return; @@ -464,7 +465,7 @@ namespace UniVRM10.VRM10Viewer throw new Exception("Failed to load the file as glTF format."); } - if (_cancellationTokenSource.Token.IsCancellationRequested) + if (cancellationToken.IsCancellationRequested) { gltfModel.Dispose(); return;