map unload fix when changing scenes

This commit is contained in:
2024-03-12 21:13:09 +02:00
parent 4a683ca2c1
commit 2900fae101

View File

@@ -423,16 +423,8 @@ namespace Game
private void UnloadMap()
{
IEnumerable<Actor> GetChildrenRecursive(Actor actor)
{
foreach (var act in actor.GetChildren<Actor>())
{
yield return act;
foreach (var child in GetChildrenRecursive(act))
yield return child;
}
}
if (!worldSpawnActor)
return;
var virtualAssets = new List<BinaryAsset>();
var allActors = GetChildrenRecursive(worldSpawnActor).ToList();
@@ -450,6 +442,17 @@ namespace Game
#if FLAX_EDITOR
Level.SceneUnloading -= OnSceneUnloading;
#endif
IEnumerable<Actor> GetChildrenRecursive(Actor actor)
{
foreach (var act in actor.GetChildren<Actor>())
{
yield return act;
foreach (var child in GetChildrenRecursive(act))
yield return child;
}
}
}
private void LoadMap(bool forceLoad)