ES2InvalidDataException on Basic Save

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
User avatar
Cranktrain
Posts: 16
Joined: Thu Nov 09, 2017 7:15 pm

ES2InvalidDataException on Basic Save

Post by Cranktrain »

Oh dear, I seem to have failed at the first hurdle with Easy Save 2.

Created a new scene, a new script, and stuck this in the Update:

Code: Select all

if (Input.GetKeyDown(KeyCode.F5)) {
	ES2.Save(123, "SavePlz");
}
Straight out of the Basic Saving and Loading Guide. But, I get this when I hit F5:

Code: Select all

ES2InvalidDataException: Easy Save 2 Error: The file provided does not contain data that is readable by Easy Save. Please make sure that file was created by Easy Save.
ES2Reader.Next ()
ES2Reader.DeleteTags (ICollection`1 tags, .ES2Writer writer)
ES2Writer.Delete ()
ES2Writer.Save (Boolean checkForOverwrite)
ES2Writer.Save ()
ES2.Save[Int32] (Int32 param, System.String identifier)
SaveAndLoadManagerSic.Update () (at Assets/SaveAndLoadTest/SaveAndLoadManagerSic.cs:23)
What am I doing that is silly? I've opened up and ran the examples provided with the package, they all work fine.

Unity 2017.2.
User avatar
Cranktrain
Posts: 16
Joined: Thu Nov 09, 2017 7:15 pm

Re: ES2InvalidDataException on Basic Save

Post by Cranktrain »

Okay, so I figured out what my issue was. My problem was that I had called ES2.Save on the same identifier ("SavePlz") with another type in a previous test, but I hadn't implemented that as a Custom Type, so it failed, but maybe got half saved? So it was expecting that type but got an int?

I had created a Settings object in the hierarchy from the Assets Dropdown option, and had selected it to File, but didn't realise I had to pass that in, so I also didn't see any file getting created and didn't think anything had been saved at all.

It wasn't until I noticed the Global Settings that I could see I was saving to PlayerPrefs and clear them and try again.

All of this confused someone new to the Asset!
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: ES2InvalidDataException on Basic Save

Post by Joel »

Hi Matt,

Sorry to hear you've been having problems with Easy Save. Hopefully I can help clear a few things up for you.

You shouldn't include a settings object in your scene, and we only include this menu item for legacy reasons. Generally if something's not in the documentation, it's either their for legacy reasons or it's internal :)

The default settings for Easy Save should be set to suitable values for most. If the save location in the default settings isn't set to File by default, it suggests that the Asset Store importer might have imported it correctly. If you wish to confirm this, create a new project and import Easy Save from the Asset Store and see if the default save location is set to File or not. I've just tried this myself and it appears to be importing correctly.

With regards to the InvalidDataException, this is indeed is usually caused by the custom type being modified. In Easy Save 2, custom types are read sequentially to improve performance, but means that some changes can invalidate the previous data. In Easy Save 3 (currently in beta), changes made to custom types do not invalidate the data.

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