Get save version from SavedGameData

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
zebialowicz.s
Posts: 2
Joined: Sun Jul 28, 2024 5:26 am

Get save version from SavedGameData

Post by zebialowicz.s »

Hi !
Im curious, is that any option to get a version number from save data without deserializing all the saves ?
Our game supports up to 99 slots for saves, each can have ~50mb data inside, which means that checking every version number once player will open loading panel is not an option, that would gives us some seconds lag every time player will open loading panel.
We have to prevent save trading, or changing names of saves because game does not support backward compatibility.
SavedGamaData has a field with version, so we can use it, but we are not sure if that's doable to read that value without deserializing all the data.

Best !
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Get save version from SavedGameData

Post by Tony Li »

Hi,

Two options:

Option 1: If you're using PlayerPrefsSavedGameDataStorer or DiskSavedGameDataStorer and you don't tick the Encrypt option, then the saved game file/string will always start with:

Code: Select all

{"m_version":7,
where "7" in this case is the version number. You can just open the file/string and read up to the first comma.


Option 2: Make your own subclass of SavedGameDataStorer that stores the version separately. For example, it could be a subclass of DiskSavedGameDataStorer that stores an int and then the saved game data string. Or your class could store each saved game file's version number in the filename or in a separate "catalog" file.
Post Reply