From 0208bad81d4cd05ed64972e861f910fb171e8702 Mon Sep 17 00:00:00 2001 From: ALEXTANG <574809918@qq.com> Date: Wed, 8 Jun 2022 10:46:23 +0800 Subject: [PATCH] Update BehaviourSingleton.cs --- .../Runtime/Core/BehaviourSingleton.cs | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/Assets/TEngine/Runtime/Core/BehaviourSingleton.cs b/Assets/TEngine/Runtime/Core/BehaviourSingleton.cs index 535927dc..bc0743d4 100644 --- a/Assets/TEngine/Runtime/Core/BehaviourSingleton.cs +++ b/Assets/TEngine/Runtime/Core/BehaviourSingleton.cs @@ -35,6 +35,10 @@ namespace TEngine { public bool IsStart = false; + public virtual void Active() + { + } + public virtual void Awake() { } @@ -85,10 +89,30 @@ namespace TEngine public void UnRegSingleton(BaseBehaviourSingleton inst) { + if (inst == null) + { + TLogger.LogError($"BaseBehaviourSingleton Is Null"); + return; + } TLogger.LogAssert(m_listInst.Contains(inst)); - m_listInst.Remove(inst); - m_listStart.Remove(inst); + if (m_listInst.Contains(inst)) + { + m_listInst.Remove(inst); + } + if (m_listStart.Contains(inst)) + { + m_listStart.Remove(inst); + } + if (m_listUpdate.Contains(inst)) + { + m_listUpdate.Remove(inst); + } + if (m_listLateUpdate.Contains(inst)) + { + m_listLateUpdate.Remove(inst); + } inst.Destroy(); + inst = null; } public override void OnUpdate()