ESave
ESave
ESave
  • ESave Documentation
  • Pro Comparison
  • đŸ•šī¸Getting Started
    • Installation
    • Example Scenes
    • Components
      • Save File Setup
      • Save Storage
  • đŸ“Ŋī¸Videos
    • Tutorial
  • 📄Scripting
    • Saving & Loading
      • Saving
      • Loading
      • Custom Serializable Objects
      • Example Script
    • Runtime Save Creation
      • Creating a Save File
      • Infinite Saves
        • Infinite Save Scripting
    • Runtime Save Deletion
    • Understanding Background Save & Load
    • Using the Save Storage
  • đŸ› ī¸Support
    • Getting Help
  • 📚Changelogs
    • Latest Releases
  • ⭐Rate Me?
Powered by GitBook
On this page
  • Deleting Specific Data
  • Deleting a File
  • Deleting All Save Files
  • Empty File
  1. Scripting

Runtime Save Deletion

Deleting saves with code.

PreviousInfinite Save ScriptingNextUnderstanding Background Save & Load

Last updated 1 month ago

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 Specific Data

As long as you have a reference to a SaveFile, you can freely delete any data.

// Where "DataID" is the ID (or key) of the saved data you'd like to delete
saveFile.DeleteData("DataID");

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 .

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();
📄
ESave Pro