Skip to content
Browse files

[SceneManagement] Fix loop skipping items when collection is modified

  • Loading branch information
Eideren authored and xen2 committed Jul 3, 2019
1 parent 5493c91 commit caa44fea8bdbc2cb19f3e9be7161635a4016a644
Showing with 6 additions and 2 deletions.
  1. +6 −2 sources/engine/Xenko.Engine/Engine/SceneInstance.cs
@@ -148,10 +148,14 @@ private void Remove(Scene scene)
scene.Entities.CollectionChanged -= Entities_CollectionChanged;
scene.Children.CollectionChanged -= Children_CollectionChanged;

foreach (var childScene in scene.Children)
var scenesToRemove = new Scene[scene.Children.Count];
scene.Children.CopyTo(scenesToRemove, 0);
foreach (var childScene in scenesToRemove)

foreach (var entity in scene.Entities)
var entitiesToRemove = new Entity[scene.Entities.Count];
scene.Entities.CopyTo(entitiesToRemove, 0);
foreach (var entity in entitiesToRemove)

0 comments on commit caa44fe

Please sign in to comment.
You can’t perform that action at this time.