Runtime Save Creation

Find out how to create saves through code.

Important Information

Before we begin, it's important to note that new SaveFile() is not always creating a new save file in the users system. It will only create a new save file if there isn't a save file in the specified path with the specified file name.

For example, if we use the same SaveFileSetupData for 2 SaveFile instances, only 1 file will be created in the user's system. The 2 SaveFile instances will simply be editing the same file.

SaveFileSetupData saveFileSetupData = new SaveFileSetupData()
{
    fileName = "Save File",
    saveLocation = SaveLocation.PersistentDataPath,
    filePath = "Example/Path",
    encryptionMethod = EncryptionMethod.None,
    addToStorage = true
};

// Both of these will be editing the same save file
SaveFile saveFile1 = new SaveFile(saveFileSetupData);
SaveFile saveFile2 = new SaveFile(saveFileSetupData);

This is here for informational purposes only, and it is not recommended to do.

Last updated