Page 1 of 1

Optimal Save Method

Posted: Wed Jan 27, 2021 12:37 pm
by Ell223
Hello,

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;
But this leads to a lot of repeated and redundant information in the save file, as it's saving the child objects, their transforms, etc- which are exactly the same for each prefab instance. I'd rather not turn off 'Save Gameobject Children' as I'm relying on this for other objects.

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);
And this works also, with a much smaller save file, but the save time goes way up.
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

Re: Optimal Save Method

Posted: Wed Jan 27, 2021 12:44 pm
by Joel
Hi Elliott,

We have a guide here regarding improving save time in this situation:
https://docs.moodkie.com/easy-save-3/es ... rformance/

All the best,
Joel

Re: Optimal Save Method

Posted: Wed Jan 27, 2021 12:49 pm
by Ell223
:oops: Doh! Sorry, somehow missed this!

Thanks.