My current method for doing this is causing a noticeable pause when trying to save 10 - 20 files.
Here's a test script that sort of replicates what I'm trying to do.
Code: Select all
using UnityEngine;
public class EasySave3PreformanceTest : MonoBehaviour
{
[Range(1, 50)]
public int numberOfSaves;
public bool saveToCache;
public bool loadFromCache;
public int[] myInts;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
SaveTest();
}
if (Input.GetKeyDown(KeyCode.N))
{
LoadTest();
}
}
private void SaveTest()
{
for (int i = 0; i < numberOfSaves; i++)
{
if (saveToCache == false)
{
ES3.Save("myInt", Random.Range(1, 101), "Preformance Test/Int Save Data " + i + ".es3");
}
else
{
// Create an ES3Settings to save to and load from the cache.
var settings = new ES3Settings(ES3.Location.Cache);
ES3.Save("myInt" + i, Random.Range(1, 101), settings);
}
}
}
private void LoadTest()
{
if (loadFromCache == false)
{
string[] fileNames = ES3.GetFiles("Preformance Test");
myInts = new int[fileNames.Length];
for (int i = 0; i < fileNames.Length; i++)
{
myInts[i] = ES3.Load<int>("myInt", "Preformance Test/" + fileNames[i]);
}
}
else
{
// Create an ES3Settings to save to and load from the cache.
var settings = new ES3Settings(ES3.Location.Cache);
myInts = new int[numberOfSaves];
for (int i = 0; i < numberOfSaves; i++)
{
myInts[i] = ES3.Load("myInt" + i, 0, settings);
}
}
}
}
I tried caching, but was unable to create the needed save files in the Save folder.