Trouble with save data in build setting

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
naruhodo469
Posts: 7
Joined: Thu Aug 31, 2023 1:21 am

Trouble with save data in build setting

Post by naruhodo469 »

When I try to build my project, the data from my previous build is still there. Is there any way to delete old data? Currently I'm using the visual novel framework's save system. Thanks.
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trouble with save data in build setting

Post by Tony Li »

Hi,

Players generally don't want to lose their saved games when updating to a newer build.

The visual novel framework's save system is the regular Dialogue System save system.

If you want to delete old saved games, there are two ways:

1. To delete all saved games, you can use a SaveSystemMethods component's DeleteSavedGameInSlot method, or C# code such as:

Code: Select all

for (int i = 0; i < 3; i++) // Assumes you have possible 3 save slots. Otherwise change this value.
{
    PixelCrushers.SaveSystem.DeleteSavedGameInSlot(i);
}
2. Or, to delete only old saved games made before the current build, do this: The Dialogue Manager GameObject has a Save System component. The Save System component has a Version value. This value defaults to 0. The Version value is saved with each saved game. Set the Save System component's Version value to a higher number (e.g., change it from 0 to 1) before making them build. When you start the game, run a C# method that checks all save slots. If a save slot has a saved game that has an older Version number, delete it. Example:

Code: Select all

for (int i = 0; i < 3; i++)
{
    var savedGameData = SaveSystem.storer.RetrieveSavedGameData(i);
    if (savedGameData.version < SaveSystem.version)
    {
        SaveSystem.DeleteSavedGameInSlot(i);
    }
}
Post Reply