I am looking for guidance on what the optimal way of saving an object is.
My current issue is that I am trying to save a list of prefab instances. I can save this list directly with e.g:
Code: Select all
ES3.Save("citizens", citizenGameobjects;
I then changed the code to only save the required components from the object, e.g:
Code: Select all
int index = 0;
foreach (Citizen citizen in Find.instance.setCitizens.Items)
{
ES3.Save(string.Format("citizen{0}storage", index), citizen.GetComponent<Storage>());
ES3.Save(string.Format("citizen{0}animatorController", index), citizen.GetComponent<AnimatorController>());
ES3.Save(string.Format("citizen{0}citizen", index), citizen);
ES3.Save(string.Format("citizen{0}transform", index), citizen.transform);
index++;
}
ES3.Save("citizenAmount", index);
The first method takes 0.17s, and the second takes 3.26s.
Is there a better way to do this, that has the quicker save time, without the repeated save information? Or is my option to turn off 'Save Gameobject Children' and rework the other save objects? But this could lead to the other objects taking up the extra time, as their child objects would need saving seperately.
Thanks,
Elliott