Runtime Save Deletion
Deleting saves with code.
Deleting saved data can be a dangerous task, as it results in the player losing their progress. Make sure saves are being deleted only when necessary (usually only when the player manually deletes them).
Deleting a File
Use the method below to completely remove a save file from the user's system.
saveFile.DeleteFile();
Deleting All Save Files
Deleting all saves is easier in ESave Pro.
Deleting all save files will require you to have a reference to all of them. Using the save storage is one way of getting save files, but only the ones with addToStorage
set to true will be available in the save storage.
// Convert to list
var saveFiles = SaveStorage.instance.saves.Values.ToList();
// Loop through all saves and delete them
foreach (var saveFile in saveFiles)
{
saveFile.DeleteFile();
}
Empty File
Alternatively, you have the option of completely removing all data while keeping the file in the user's system.
saveFile.EmptyFile();
Last updated