This issue is a bit confusing to me because when i open the save data to see the townbuildings vs the animals, neither of them store references to their children. I am assuming this is because it doesn't need to save them if it plans to instantiate the prefab at runtime. So this doesn't explain why the chickens dont have their child objects. I can solve this by putting autosave component on them with save children, but this saves a lot of unnecessary data to the save file and still doesn't answer this inconsistency.
for reference, this is the load routine in my TownManager:
Code: Select all
private void LoadEventHandler(EventQueueType eventQueueType, string eventParameter, int quantity)
{
//We only need to load player town builders if the player is actually in their town scene
if (LevelManager.instance.ActiveSceneName != "Overworld_PlayerTown")
return;
if(ES3.KeyExists("PlayerTown_BuildingsGameObjects"))
{
TownBuildingGameobjects = ES3.Load("PlayerTown_BuildingsGameObjects", new List<GameObject>());
}
if (ES3.KeyExists("PlayerTown_Buildings"))
{
TownBuildings = ES3.Load("PlayerTown_Buildings", new List<TownBuilding>());
}
if(ES3.KeyExists("PlayerTown_NonUniqueBuildings"))
{
nonUniqueBuildings = ES3.Load("PlayerTown_NonUniqueBuildings", new Dictionary<string, TownBuilding>());
}
RebuildNPCBuildingReference();
foreach (string guid in nonUniqueBuildings.Keys)
{
nonUniqueBuildings[guid].GetComponent<AnimalStructure>().LoadFromDisk();
}
}
Code: Select all
public void LoadFromDisk()
{
if (ES3.KeyExists(string.Format("{0}_{1}", structureName.Replace(" ", ""), Ref_TownBuilding.Guid)))
{
animalGameobjects = ES3.Load(string.Format("{0}_{1}", structureName.Replace(" ", ""), Ref_TownBuilding.Guid), new List<GameObject>());
animalInventory.LoadInventoryFromDisk();
foodInventory.LoadInventoryFromDisk();
produceInventory.LoadInventoryFromDisk();
}
}