From aec125fb4e5c37f2e5d39d9ba3c6ffef93c907af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Hodossy?= Date: Wed, 14 Dec 2022 13:38:36 +0000 Subject: [PATCH] Check whether MjScene exists in components' OnDisable() --- unity/Runtime/Components/MjComponent.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unity/Runtime/Components/MjComponent.cs b/unity/Runtime/Components/MjComponent.cs index 1371c001..3b69668f 100644 --- a/unity/Runtime/Components/MjComponent.cs +++ b/unity/Runtime/Components/MjComponent.cs @@ -99,7 +99,7 @@ public abstract class MjComponent : MonoBehaviour { } public void OnDisable() { - if (!_exiting) { + if (!_exiting && MjScene.InstanceExists) { MjScene.Instance.SceneRecreationAtLateUpdateRequested = true; } }