From c51eda49bff7298019a677ce8815510f94cc5dd2 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Fri, 27 Sep 2024 18:38:24 +0300 Subject: [PATCH] fix: GameManager Instantiation/Deletion during Update causing Array Changed Exception --- Engine.Core/GameManager.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Engine.Core/GameManager.cs b/Engine.Core/GameManager.cs index 811abd0..7e9b1cc 100644 --- a/Engine.Core/GameManager.cs +++ b/Engine.Core/GameManager.cs @@ -89,14 +89,14 @@ public class GameManager : BaseEntity, IGameManager public void Update(EngineTime time) { Time.SetTime(time); - foreach (var gameObject in GameObjects) - gameObject.BehaviourController.Update(); + for (int i = 0; i < GameObjects.Count; i++) + GameObjects[i].BehaviourController.Update(); } public void PreDraw() { - foreach (var gameObject in GameObjects) - gameObject.BehaviourController.UpdatePreDraw(); + for (int i = 0; i < GameObjects.Count; i++) + GameObjects[i].BehaviourController.UpdatePreDraw(); } /////////////////////////////////////////////////////////////////