diff --git a/UnityProject/Assets/TEngine/Runtime/Modules/ModuleCore/ModuleImpSystem.cs b/UnityProject/Assets/TEngine/Runtime/Modules/ModuleCore/ModuleImpSystem.cs index f5ab8271..1010da38 100644 --- a/UnityProject/Assets/TEngine/Runtime/Modules/ModuleCore/ModuleImpSystem.cs +++ b/UnityProject/Assets/TEngine/Runtime/Modules/ModuleCore/ModuleImpSystem.cs @@ -19,6 +19,7 @@ namespace TEngine private static readonly GameFrameworkLinkedList _modules = new GameFrameworkLinkedList(); private static readonly GameFrameworkLinkedList _updateModules = new GameFrameworkLinkedList(); private static readonly List _updateExecuteList = new List(DesignModuleCount); + private static bool _isExecuteListDirty; /// /// 所有游戏框架模块轮询。 @@ -27,6 +28,12 @@ namespace TEngine /// 真实流逝时间,以秒为单位。 public static void Update(float elapseSeconds, float realElapseSeconds) { + if (_isExecuteListDirty) + { + _isExecuteListDirty = false; + BuildExecuteList(); + } + int executeCount = _updateExecuteList.Count; for (int i = 0; i < executeCount; i++) { @@ -149,12 +156,20 @@ namespace TEngine { _updateModules.AddLast(moduleImp); } - - _updateExecuteList.Clear(); - _updateExecuteList.AddRange(_updateModules); + + _isExecuteListDirty = true; } return moduleImp; } + + /// + /// 构造执行队列。 + /// + private static void BuildExecuteList() + { + _updateExecuteList.Clear(); + _updateExecuteList.AddRange(_updateModules); + } } } \ No newline at end of file