Load older save file - adding new variables

Hi,

I have a porblem with loading a save file which is form an older version of my game.

I save my Game every Frame and it gets saved as json.

And I load it like that:

public PlayerData data;
void Awake()
    {
        if (SaveLoadManager.LoadJson() != null)
        {
            data = SaveLoadManager.LoadJson();
        }
    }
public static PlayerData LoadJson()
    {
        if (!File.Exists(Application.persistentDataPath + saveFileName))
        {
            return null;
        }
        string decrypted = LoadEncrypt();
        return JsonUtility.FromJson<PlayerData>(decrypted);
    }

My PlayerData Class has a lot of values. My problem is if I add a new value to the PlayerData Class and If I load the game it is 0.

I think the problem is inside the Awake() function, because I basically say “class equals class”.

How can I handle the loading more properly also if I add new variables to the class? Can anyone help me on that?

Thank’s in Advance!

Nevermind I got it instead of data = SaveLoadManager.LoadJson(); I used `JsonUtility.FromJsonOverwrite(SaveLoadManager.LoadJson(), data);``and make the class return the json string instead of the PlayerData class.