From 7c372a60a22a28ea36d3c37ba372d2daeb57326f Mon Sep 17 00:00:00 2001
From: ALEXTANG <574809918@qq.com>
Date: Wed, 8 Jun 2022 10:37:28 +0800
Subject: [PATCH] Update BehaviourSingleton.cs
---
.../Runtime/Core/BehaviourSingleton.cs | 20 ++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/Assets/TEngine/Runtime/Core/BehaviourSingleton.cs b/Assets/TEngine/Runtime/Core/BehaviourSingleton.cs
index 8c34594e..535927dc 100644
--- a/Assets/TEngine/Runtime/Core/BehaviourSingleton.cs
+++ b/Assets/TEngine/Runtime/Core/BehaviourSingleton.cs
@@ -1,11 +1,11 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Collections.Generic;
namespace TEngine
{
+ ///
+ /// 通过LogicSys来驱动且具备Unity完整生命周期的单例(不继承MonoBehaviour)
+ ///
+ ///
public class BehaviourSingleton : BaseBehaviourSingleton where T : BaseBehaviourSingleton, new()
{
private static T sInstance;
@@ -83,13 +83,19 @@ namespace TEngine
m_listStart.Add(inst);
}
+ public void UnRegSingleton(BaseBehaviourSingleton inst)
+ {
+ TLogger.LogAssert(m_listInst.Contains(inst));
+ m_listInst.Remove(inst);
+ m_listStart.Remove(inst);
+ inst.Destroy();
+ }
+
public override void OnUpdate()
{
var listStart = m_listStart;
-
var listToUpdate = m_listUpdate;
var listToLateUpdate = m_listLateUpdate;
-
if (listStart.Count > 0)
{
for (int i = 0; i < listStart.Count; i++)