FormatException when loading save file

Discussion and help for Easy Save 3
Post Reply
User avatar
Dorcan
Posts: 3
Joined: Mon Jul 12, 2021 3:35 pm

FormatException when loading save file

Post by Dorcan »

Hello!

First of all, thanks a lot for this excellent plugin. We've integrated it into our two previous released games, and it worked very well. :)

So in our current project, we have a GameVariable class which has a "value" field of type "System.object".
Some time ago everything was working fine, I could save the game variables and reload them, but now I get this error when loading:

Code: Select all

FormatException: Expected '{' or "null", found 'f'.
So what I found out is that the JSON is saved a bit differently than before concerning System.object variables.

This is the problematic part in the save file:

Code: Select all

{	
		"name" : "Active",
		"value" : false
}
And that is the same part, but how it was saved sometime ago:

Code: Select all

{	
		"name" : "Active",
		"value" : {
			"__type" : "bool"false
		}
}
So between the previous version and the current version of the game, I didn't modify the class which is serialized by EasySave3, but what I did was quite some refactoring and finishing dividing ALL code files in several assemblies. This created quite some problems with EasySave3, because it couldn't recognize the primitive types anymore as there were no more Assembly-CSharp.dll and Assembly-CSharp-firstpass generated by Unity. So what I gained in compilation time, I lost in ES3 functionality :(

I ended up removing the assembly definition I added in EasySave3 folder, and I extracted my "save bridge code" out of another assembly in order to make the save work.

But now ES3 doesn't save object type correctly.

What can I do ? Thanks ! :mrgreen:
Daniel
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: FormatException when loading save file

Post by Joel »

Hi there,

Are you using the latest version of Easy Save? We had the issue where the format changed for one version, but this was changed back in the latest version. You can find the version in Assets > Plugins > Easy Save 3 > Change Log.

If updating doesn't resolve your issue, please could you replicate this in a new, empty project with a simple scene using the version of Easy Save used to create your save file, and private message it to me with instructions.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
User avatar
Dorcan
Posts: 3
Joined: Mon Jul 12, 2021 3:35 pm

Re: FormatException when loading save file

Post by Dorcan »

Hey Joel,

When the saving was working, EasySave version was 3.3.2f3. I actually updated ES3 when I came across the issue, hoping it would fix it, but the 3.3.2f5 version didn't.

I'll send you a test scene by PM.

Thanks !
User avatar
Dorcan
Posts: 3
Joined: Mon Jul 12, 2021 3:35 pm

Re: FormatException when loading save file

Post by Dorcan »

Ok while I was preparing a package to send you I found out the problem: it's the last ES3 version (3.3.2f5). I think I mixed up the chronology here because I was sure I updated ES3 AFTER encountering the issue, but I actually did it for another one. :roll:

Reverting ES3 folder to a previous version did the trick. So with a diff tool I found out that the problem was in ES3Writer at line 184:

Code: Select all

if (!type.isCollection && !type.isDictionary && !type.isPrimitive)
My variable is most of the time a primitive in my case, that's why when I updated to the latest ES3 version, it didn't work anymore. Removing "&&!type.isPrimitve" corrected my issue with the new ES3 version ! :)
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: FormatException when loading save file

Post by Joel »

Hi there,

It looks like this change was meant to be pushed to 3.3.2f5 but wasn't for some reason. This change will be pushed in the upcoming update.

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