Handling of change of field or key type

Vote for new features, or make your own requests here.
Post Reply

Handling of change of field or key type

Yes, I would like this feature
No, I would not like this feature
No votes
Total votes: 1

User avatar
Moodkie Staff
Posts: 4018
Joined: Wed Nov 07, 2012 10:32 pm

Handling of change of field or key type

Post by Joel »






Some method of handling previously saved field which has since has it's data type changed without creating an ES3Type.

The most effective way of doing this is likely to be using attributes, similar to Unity's FormerlySerializedAsAttribute.

Note that there currently exists a solution to this: to turn off type checking and ensure that you're providing the precise type of the object as the generic parameter when saving and loading (i.e. not using an inherited class as the generic parameter). The following script demonstrates this:

Code: Select all

using UnityEngine;

public class ChangedTypeTest : MonoBehaviour
    void Start()
        ES3Settings.defaultSettings.typeChecking = false;

        OriginalClass originalClass = new OriginalClass();
        originalClass.myInt = 456;

        ES3.Save<OriginalClass>("myKey", originalClass);

        RenamedClass renamedClass = ES3.Load<RenamedClass>("myKey");

    public class OriginalClass
        public int myInt = 123;

    public class RenamedClass
        public int myInt;
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started

Post Reply