Currently OnApplicationQuit I'm saving dungeon_tiles instantiated prefabs into a file and some of the dungeon rooms children gameobjects into another file (in this case the dungeon walls with Doorway script, because I need to save if the walls children are removed from the scene or not, since they hold the collision and meshrenderer).
Then on Start I load the dungeon rooms, then I load the dungeon_doorways file right after.
The problem is that seems Doorway children are still spawned despite the fact they are destroyed.
What I'd expect is that the children would get removed when I load the second file.
To clarify here is the Start()
Code: Select all
dungeonDoorwaysSave = new ES3Settings("dungeon_doorways.save") {saveChildren = true};
playerSave = new ES3Settings("players_data.save") {saveChildren = true};
worldSave = new ES3Settings("world.save");
if (load)
{
dungeonTiles = ES3.Load("dungeon_tiles", dungeonTiles, worldSave);
pickupables = ES3.Load("pickupables", pickupables, worldSave);
rigidbodies = ES3.Load("rigidbodies", rigidbodies, worldSave);
dungeonDoorways = ES3.Load("dungeon_doorways", dungeonDoorways, dungeonDoorwaysSave);
players = ES3.Load("players", players, playerSave);
}
OnApplicationQuit
Code: Select all
if (!save)
return;
Debug.Log("QUIT GAME, SAVING...");
foreach (var entry in FindAllObjectsOfType<Tile>())
dungeonTiles.Add(entry.gameObject);
foreach (var entry in FindAllObjectsOfType<PlayerStats>())
players.Add(entry.gameObject);
foreach (var entry in FindAllObjectsOfType<Doorway>())
dungeonDoorways.Add(entry.gameObject);
foreach (var entry in FindAllObjectsOfType<Rigidbody>())
{
if (!PlayersManager.instance.playersTransforms.Contains(entry.transform))
rigidbodies.Add(entry.gameObject);
}
ES3.Save("dungeon_tiles", dungeonTiles, worldSave);
ES3.Save("pickupables", pickupables, worldSave);
ES3.Save("rigidbodies", rigidbodies, worldSave);
ES3.Save("dungeon_doorways", dungeonDoorways, dungeonDoorwaysSave);
ES3.Save("players", players, playerSave);
What I even tried is this on Start: iterate the just spawned walls and remove them, then load them again from the other file dungeon_doorways with no success, no GameObject is spawned.
Code: Select all
dungeonTiles = ES3.Load("dungeon_tiles", dungeonTiles, worldSave);
pickupables = ES3.Load("pickupables", pickupables, worldSave);
rigidbodies = ES3.Load("rigidbodies", rigidbodies, worldSave);
foreach (var tile in dungeonTiles)
{
foreach (var doorway in tile.GetComponentsInChildren<Doorway>())
{
Destroy(doorway.gameObject);
}
}
dungeonDoorways = ES3.Load("dungeon_doorways", dungeonDoorways, dungeonDoorwaysSave);
players = ES3.Load("players", players, playerSave);