ES2 -> ES3 equivalents?

Discussion and help for Easy Save 3
Post Reply
zapposh
Posts: 9
Joined: Wed Jan 17, 2018 7:31 am

ES2 -> ES3 equivalents?

Post by zapposh »

Hi,

I'm upgrading my projects from ES2 to ES3, and for the most part have got things working as they should.
But in some cases I simply could not find the equivalent to what was used in ES2, even after hours in the docs and trying out things.

Something like this does not work anymore in ES3:
settings = new ES3Settings();
settings.saveLocation = ES3Settings.SaveLocation.Memory;
(saveLocation not supported)

What is the equivalent of this in ES3?
byte[] bytes = writer.stream.ReadAllBytes();
(stream not supported)

Same question here. What to use instead of ReadArray, which is not supported anymore?
var bytes = ES3.LoadRawBytes("progressBytes");
using (ES3Reader reader = ES3Reader.Create(bytes, settings))
{
.
.
unlockedLevels = reader.ReadArray<bool>();
.
.
reader.Dispose();
}

Unity 2017.41f1

Thanks.
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: ES2 -> ES3 equivalents?

Post by Joel »

Hi there,

Instead of using readers and writers, Easy Save 3 uses an ES3File to cache data and then read from it. It's much simpler than ES2Reader/ES2Writer, and has the same performance benefits: http://docs.moodkie.com/easy-save-3/es3 ... g-es3file/

For example, the equivalent of your code would simply be:
// Create a new ES3File, which will automatically load the default file into it.
var es3file = new ES3File();
// Load from the ES3File.
unlockedLevels = es3File.Load<bool[]>("myKey");
Also note that there is no longer sequential writing or reading, but as ES3File caches the data into a Dictionary, random-access is extremely fast so sequential reading/writing is no longer necessary.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
zapposh
Posts: 9
Joined: Wed Jan 17, 2018 7:31 am

Re: ES2 -> ES3 equivalents?

Post by zapposh »

Thank you for your super fast replay.
Ok, I'll go with the ES3File method.

I need the sequential bytes to save to the xbox managed/connected storage, but I suppose I can extract those from the dictionary then.

Thanks again.
zapposh
Posts: 9
Joined: Wed Jan 17, 2018 7:31 am

Re: ES2 -> ES3 equivalents?

Post by zapposh »

Sorry, just found the answer to my problem in the docs:
To convert the ES3File to a byte array or string, use the ES3File.LoadRawBytes and ES3File.LoadRawString methods.

Exactly what I need ! :-)
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: ES2 -> ES3 equivalents?

Post by Joel »

Glad you managed to find the info!

Note that there's also a constructor for the ES3File which accepts a byte array, and you can also write more data to the ES3File using the es3File.Save<T>(string key) methods.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply