From 700f79a7009f120e369108cdad2d143ece3d6356 Mon Sep 17 00:00:00 2001 From: notargs Date: Wed, 6 Apr 2022 17:48:44 +0900 Subject: [PATCH] Fix FastSpringBoneService initializing flow for #1567 --- .../FastSpringBone/System/FastSpringBoneService.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Assets/VRM10/Runtime/FastSpringBone/System/FastSpringBoneService.cs b/Assets/VRM10/Runtime/FastSpringBone/System/FastSpringBoneService.cs index e4df6e851..d3e103977 100644 --- a/Assets/VRM10/Runtime/FastSpringBone/System/FastSpringBoneService.cs +++ b/Assets/VRM10/Runtime/FastSpringBone/System/FastSpringBoneService.cs @@ -16,6 +16,9 @@ namespace UniVRM10.FastSpringBones.System { if (_instance) return _instance; + _instance = FindObjectOfType(); + if (_instance) return _instance; + var gameObject = new GameObject("FastSpringBone Service"); DontDestroyOnLoad(gameObject); _instance = gameObject.AddComponent(); @@ -33,14 +36,15 @@ namespace UniVRM10.FastSpringBones.System _instance = null; } - private void Awake() + private void OnEnable() { BufferCombiner = new FastSpringBoneBufferCombiner(); _fastSpringBoneScheduler = new FastSpringBoneScheduler(BufferCombiner); } - private void OnDestroy() + private void OnDisable() { + BufferCombiner.Dispose(); _fastSpringBoneScheduler.Dispose(); }