I'm looking at adapting my save system to use the cache to increase performance, but I'm having some issues getting started. I made a simple script from the cache example to try and get the workflow working but I can't seem to find the final file written anywhere. I'm not getting any errors when testing, but no file to be found after saving. I'm sure that I'm just missing something super simple. Thanks in advance!
Code: Select all
using UnityEngine;
public class SimpleCacheSave : MonoBehaviour {
[SerializeField] public static ES3Settings settings;
private string saveRoot = "SaveData";
private string saveFileName = "Test Shelter";
private string saveName = "Test Shelter";
// Start is called before the first frame update
private void Awake () {
settings = new ES3Settings ();
settings.location = ES3.Location.Cache;
settings.path = saveRoot + "/" + saveFileName + "/" + saveName;
settings.directory = ES3.Directory.PersistentDataPath;
settings.memberReferenceMode = ES3.ReferenceMode.ByRefAndValue;
ES3.CacheFile (settings);
}
private void Update () {
if (Input.GetKey (KeyCode.F8))
Save ();
if (Input.GetKey (KeyCode.F9))
WriteCache ();
}
public void Save () {
ES3.Save ("myInt", 123, settings);
ES3.Save ("myTransform", this.transform, settings);
}
public void WriteCache () {
ES3.CacheFile (settings.path, settings);
}
}