Optimising game saving

Hi there,

I’m using ES2 to save my game data, however I need some help on making it faster.

Basically I have about 100 AI characters, each with about 20 values that need to be saved. Currently I loop through each character and save these values one by one. This works, but the problem is that it can take upwards to 20 seconds to save them all!

I am able to optimise it a bit by obviously only saving the values that aren’t default, but other than that I don’t know what to do.

Any ideas?

This may take a little effort in rewritting the code, but you could theoretically update your save data when you update your AI characters. let’s say you have the save data serialized as Json, simply update the json data as you update any value of the AI character.

But 20 seconds seems a lot, even if you do it all at once. You could try other ways of serialization with xml or json. One link I have found: https://docs.unity3d.com/Manual/JSONSerialization.html

I personally use this plugin: Unity Asset Store - The Best Assets for Game Making
But I cannot say for sure if changing to another json serialization will massively improve your time. If it does not, try the approach I first mentioned: Keep the serialized data parallel to your ingame data and update the serialized data when you update your ingame data. Then you can save the serialized data immediately, since it is already complete.