I recently switched from purely saving and loading directly from files to using a cache file instead.
Saving and loading values from the cache works perfectly fine, however when I call StoreCachedFile, the file is updated but doesn't contain any of the expected keys.
When I create a new game I do the following:
Code: Select all
//Create a SaveData object which contains some information (game creation date etc) and generates a unique file name.
CurrentSave = new SaveData(SaveSlotsPath);
//Save the SaveData Object as a key in a new file
ES3.Save(SaveDataKey, CurrentSave, saveFilePath);
//Loading that file into cache
ES3.CacheFile(saveFilePath);
//Create a new ES3Settings
cacheSettings = new ES3Settings(ES3.Location.Cache);
Code: Select all
public static T Load<T>(string key, T defaultValue = default)
{
return CurrentSave == null ? defaultValue : ES3.Load(key, defaultValue,cacheSettings);
}
public static void Save<T>(string key, T value)
{
ES3.Save(key, value, cacheSettings);
}
Code: Select all
public static void SaveToCurrentFile()
{
if (CurrentSave != null)
ES3.StoreCachedFile(saveFilePath, cacheSettings); //I tried with and without the cacheSettings parameter
}