Unity serializer will not save integers which have a value of zero

I am using the Unity Serializer from WhyDoItDoIt (in Asset store for free) and have an issue with integers have a value of zero. Let me explain quickly.

I have public variables in javascript which have an initial value of zero. When I save the game, change the value to 1, and load the game, the value is still 1. I have tried this when the variable is initially not zero like 1 and then it works so the issue is especially with the value zero. It almost looks like the value of zero is ignored when saving the level.

I have also tried this with one of the example scenes. I have loaded the ExampleObjectSaveAndLoad scene which comes with the package where there is only one gameobject in the scene with two variables of which one is an integer. If you run the scene, change the value to zero, press S to save the object, change the value to one and press L to load the scene, the value is still 1 instead of 0. So even with the out of the box example scene it does not work.

I have tried this with other scenes and the behavior seems to be consistent.

Is there anyone who has encountered the same issue? Is this introduced with the latest release? If you don’t have this issue, what version are you using. Any help much appreciated here!

Most kind, thank you!

So I’ve worked out what it is - not actually the caching. Unfortunately I didn’t verify that when using LoadNow that default values were written back to the objects already present. PauseMenu used to use .Load on the SaveGameEntry which will work fine for you as it reloads the level and hence resets the defaults. The LoadNow methods don’t reload the scene so don’t overwrite default values (which are not saved by default!).

I think the safest choice is going to be disabling the default value checking unfortunately, and always save everything. I’m preparing a version. For now mod PauseMenu.js to use sg.Load() rather than LevelSerializer.LoadNow(sg.Data);