StoreCachedFile is not updating my file with expected values
Posted: Tue Aug 24, 2021 3:40 pm
Hi,
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:
loading and saving keys into the cache when the game runs works perfectly fine
However, when I want to dump the cache back into the file by calling this method, my file is updated (modification date of the file is updated), but it still only contains the "SaveData" key, and nothing else.
I suppose somehow I'm reading from the wrong cache or something. It's not quite clear to me what's going on. I'm 100% positive the cache does contain my keys, otherwise my game wouldn't be able to remember that an object is gone when I go from a scene to another and back.
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
}