Versioning

Discussion and help for Easy Save 3, The Complete Save Game & Data Serializer System for the Unity Engine
Post Reply
aschearer
Posts: 5
Joined: Fri Oct 16, 2020 9:14 pm

Versioning

Post by aschearer »

Hi I'm curious how people handle upgrading/versioning their data using Easy Save? For example, what if a field is deleted? Or if a field's type changes?
User avatar
Joel
Moodkie Staff
Posts: 4986
Joined: Wed Nov 07, 2012 10:32 pm

Re: Versioning

Post by Joel »

Hi there,

Easy Save automatically handles cases where a field is deleted, so you don't need to do anything.

If the type of a field changes, you can disable type checking in Easy Save's settings (or provide an ES3Settings object with type checking disabled). Easy Save will try to load the data of the old type in the form of the new type.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
RiseBasti
Posts: 7
Joined: Tue Nov 01, 2022 7:09 am

Re: Versioning

Post by RiseBasti »

Hi,

I hope it's alright to revive this thread. I've been thinking a lot about versioning, and while the examples provided by aschearer are helpful, they don't seem to cover every scenario.
Currently, I don't have any immediate issues with versioning, but I'm concerned that I'm not planning far enough ahead, which might cause saved games to break in future updates. For instance, in my latest update (which is still in internal testing), many variables changed and could no longer be loaded correctly.

Here's what I've got covered so far:
- Deleting variables (they just can't be loaded and get overwritten)
- Creating new variables (a new variable is simply added)
- Changing the type of an existing variable (as mentioned, ES3 seems to handle this somehow)

However, I'm unsure about the following:
- Renaming variables / Transforming "old" data into new variables

For example: Let's say I have a variable called "MyVar", but in a new version, it either gets renamed to "NewVar", or "MyVar" is removed, and "NewVar" is introduced as a replacement.

How would I go about retrieving the old variable and transforming its data into the new one? (I use the word "transform" because the new variable might not take the exact same value and may require changes.)

Is there a way to manage this situation effectively?

Thanks in advance for any advice!
User avatar
Joel
Moodkie Staff
Posts: 4986
Joined: Wed Nov 07, 2012 10:32 pm

Re: Versioning

Post by Joel »

Hi there,

Please could you update the invoice number on your profile as per the instructions here and let me know when you have done so as this is now a requirement for support: https://moodkie.com/forum/viewtopic.php?t=3014

Generally in these cases you would create an ES3Type for the class and modify it so that it reads both the old and new variable name. I.e. in the switch statement of the Read method of the ES3Type, just modify this:

case "OldName":

To:

case "OldName":
case "NewName":

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
RiseBasti
Posts: 7
Joined: Tue Nov 01, 2022 7:09 am

Re: Versioning

Post by RiseBasti »

Hi Joel,

thank you for your answer.
I just updated my profile with the invoice number.

This is perfect and i think that should sholve any problem that might arise. Do I also need to include the "oldVar" name in the "[ES3PropertiesAttribute("oldVar", "newVar")] at the top of the ES3Type or is the additional case sufficient?

Thanks again for your support and for ES3 in generall.
User avatar
Joel
Moodkie Staff
Posts: 4986
Joined: Wed Nov 07, 2012 10:32 pm

Re: Versioning

Post by Joel »

Hi there,

You don't need to do anything with the ES3Properties attribute, this is just used to tell the Types window what variables are selected, so is not important if you're customising the ES3Type.

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