Saving with Cache

Discussion and help for Easy Save 3
Post Reply
tmarshall619
Posts: 1
Joined: Thu Nov 04, 2021 11:08 pm

Saving with Cache

Post by tmarshall619 »

Hello!

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);
    }
}
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving with Cache

Post by Joel »

Hi there,

I don't appear to see anywhere in your code where you're calling ES3.StoreCachedFile, so it will never be stored to file.

For more information please see the guide:
https://docs.moodkie.com/easy-save-3/es ... rformance/

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply