From f3e0e8e41799a2f6526cd147f0bab2545e3c7808 Mon Sep 17 00:00:00 2001 From: tsgcpp <19503967+tsgcpp@users.noreply.github.com> Date: Sat, 30 Dec 2023 00:20:52 +0900 Subject: [PATCH] fix: Skip Vrm10Runtime instantiation after the GameObject is destroyed --- .../Runtime/Components/Vrm10Instance/Vrm10Instance.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Assets/VRM10/Runtime/Components/Vrm10Instance/Vrm10Instance.cs b/Assets/VRM10/Runtime/Components/Vrm10Instance/Vrm10Instance.cs index c871b2650..50e95c47e 100644 --- a/Assets/VRM10/Runtime/Components/Vrm10Instance/Vrm10Instance.cs +++ b/Assets/VRM10/Runtime/Components/Vrm10Instance/Vrm10Instance.cs @@ -95,6 +95,7 @@ namespace UniVRM10 { if (m_runtime == null) { + if (this == null) throw new MissingReferenceException("instance was destroyed"); m_runtime = new Vrm10Runtime(this, m_useControlRig); } return m_runtime; @@ -138,7 +139,11 @@ namespace UniVRM10 private void OnDestroy() { - Runtime.Dispose(); + if (m_runtime != null) + { + m_runtime.Dispose(); + m_runtime = null; + } } private void OnDrawGizmosSelected()