Save Version
5_ScriptableSave
You might have noticed that I added a Version int in the SaveData. This is an example, but it's a great way to detect if a save file is from an older version.

For developers who have worked on live games, when you add a new feature or refactor some elements, the save data structure might change. In these cases, you need to upgrade the old data structure to the new one. Scriptable Save provides two methods that you can override to suit your needs:
protected override void UpgradeData(SaveData oldData)
{
if (_debugLogEnabled)
Debug.Log("Upgrading data from version " + oldData.Version + " to " + _saveData.Version);
// Implement additional upgrade logic here
oldData.Version = _saveData.Version;
}
protected override bool NeedsUpgrade(SaveData saveData)
{
return saveData.Version < _saveData.Version;
}
Last updated