diff --git a/Assets/VRM/Runtime/SpringBone/Jobs/Vrm0XFastSpringBoneRuntime.cs b/Assets/VRM/Runtime/SpringBone/Jobs/Vrm0XFastSpringBoneRuntime.cs index 1a398c2a38..9d8c8e5a6b 100644 --- a/Assets/VRM/Runtime/SpringBone/Jobs/Vrm0XFastSpringBoneRuntime.cs +++ b/Assets/VRM/Runtime/SpringBone/Jobs/Vrm0XFastSpringBoneRuntime.cs @@ -22,10 +22,14 @@ public class Vrm0XFastSpringboneRuntime : IVrm0XSpringBoneRuntime SpringBoneJobs.FastSpringBoneService m_service; FastSpringBoneBuffer m_buffer; + public Vrm0XFastSpringboneRuntime() + { + m_service = SpringBoneJobs.FastSpringBoneService.Instance; + } + public async Task InitializeAsync(GameObject vrm, IAwaitCaller awaitCaller) { m_vrm = vrm; - m_service = SpringBoneJobs.FastSpringBoneService.Instance; // default update の停止 foreach (VRMSpringBone sb in vrm.GetComponentsInChildren()) @@ -69,9 +73,8 @@ async Task RegisterAsync(IAwaitCaller awaitCaller) public void ReconstructSpringBone() { - var disposer = m_vrm.gameObject.GetComponent(); Unregister(); - var task = RegisterAsync(new ImmediateCaller()); + var _ = RegisterAsync(new ImmediateCaller()); } public void RestoreInitialTransform() diff --git a/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntime.cs b/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntime.cs index 75793c5b10..1732f56693 100644 --- a/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntime.cs +++ b/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntime.cs @@ -19,6 +19,11 @@ public class Vrm10FastSpringboneRuntime : IVrm10SpringBoneRuntime private FastSpringBones.FastSpringBoneService m_fastSpringBoneService; private FastSpringBoneBuffer m_fastSpringBoneBuffer; + public Vrm10FastSpringboneRuntime() + { + m_fastSpringBoneService = FastSpringBones.FastSpringBoneService.Instance; + } + public void SetJointLevel(Transform joint, BlittableJointMutable jointSettings) { if (m_fastSpringBoneService.BufferCombiner.Combined is FastSpringBoneCombinedBuffer combined) @@ -37,7 +42,6 @@ public void SetModelLevel(Transform modelRoot, BlittableModelLevel modelSettings public async Task InitializeAsync(Vrm10Instance instance, IAwaitCaller awaitCaller) { - m_fastSpringBoneService = FastSpringBones.FastSpringBoneService.Instance; m_instance = instance; // NOTE: FastSpringBoneService は UnitTest などでは動作しない @@ -49,8 +53,11 @@ public async Task InitializeAsync(Vrm10Instance instance, IAwaitCaller awaitCall public void Dispose() { - m_fastSpringBoneService.BufferCombiner.Unregister(m_fastSpringBoneBuffer); - m_fastSpringBoneBuffer.Dispose(); + if (m_fastSpringBoneBuffer != null) + { + m_fastSpringBoneService.BufferCombiner.Unregister(m_fastSpringBoneBuffer); + m_fastSpringBoneBuffer.Dispose(); + } } /// diff --git a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs index 0543f9f6c3..dacfdedf7b 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs @@ -286,14 +286,15 @@ protected override async Task FinalizeAsync(IAwaitCaller awaitCaller) if (UniGLTF.Extensions.VRMC_springBone.GltfDeserializer.TryGet(Data.GLTF.extensions, out UniGLTF.Extensions.VRMC_springBone.VRMC_springBone springBone)) { await LoadSpringBoneAsync(awaitCaller, controller, springBone); + } - if (Application.isPlaying) - { - // EditorImport では呼ばない - // Vrm10Runtime で初期化していたが、 async にするためこちらに移動 v0.127 - // RuntimeGltfInstance にアクセスしたいのだが OnLoadHierarchy ではまだ attach されてなかった v0.128 - await m_springboneRuntime.InitializeAsync(controller, awaitCaller); - } + if (Application.isPlaying) + { + // EditorImport では呼ばない + // Vrm10Runtime で初期化していたが、 async にするためこちらに移動 v0.127 + // RuntimeGltfInstance にアクセスしたいのだが OnLoadHierarchy ではまだ attach されてなかった v0.128 + // VRMC_springBone が無くても初期化する v0.127.2 + await m_springboneRuntime.InitializeAsync(controller, awaitCaller); } // constraint