From e53ceb0095b70f1d607785fcbcd72f876b890d1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E6=8C=BA?= Date: Tue, 9 Jul 2024 18:49:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E4=BE=8B=E5=AF=B9=E8=B1=A1=E9=94=80?= =?UTF-8?q?=E6=AF=81=E6=97=B6=E7=9A=84=E6=A3=80=E6=9F=A5=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E7=94=B1=E6=AD=A4=E9=94=99=E8=AF=AF=E7=9A=84=E9=94=80?= =?UTF-8?q?=E6=AF=81=E5=8D=95=E4=BE=8B=E5=AF=B9=E8=B1=A1=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GameScripts/HotFix/GameBase/SingletonBehaviour.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/UnityProject/Assets/GameScripts/HotFix/GameBase/SingletonBehaviour.cs b/UnityProject/Assets/GameScripts/HotFix/GameBase/SingletonBehaviour.cs index 91010dbc..16f3f067 100644 --- a/UnityProject/Assets/GameScripts/HotFix/GameBase/SingletonBehaviour.cs +++ b/UnityProject/Assets/GameScripts/HotFix/GameBase/SingletonBehaviour.cs @@ -36,7 +36,10 @@ namespace GameBase protected virtual void OnDestroy() { - Release(); + if (this == _instance) + { + Release(); + } } /// @@ -60,7 +63,7 @@ namespace GameBase if (_instance != null) { SingletonSystem.Release(_instance.gameObject); - _instance = null; + _instance = null; } } @@ -96,7 +99,7 @@ namespace GameBase } } - if(_instance == null) + if (_instance == null) { Log.Error($"Can't create SingletonBehaviour<{typeof(T)}>"); }