Recently, my game is onlion with the EasySave3. I save game data by Cache and StoreCachedFile, but some users meet the problem as the subject when they load game data, and they are always loading on the start scene.(This appears to be the case with only some mobile phones)
Next is my function code.
Code: Select all
public const string GAME_PATH = "GameSaved.es3";
public void SaveGameBasic()
{
var settings = new ES3Settings(Config.GAME_PATH, ES3.Location.Cache);
saveBasic.UpdateSaveBasic();
ES3.Save("SaveBasic", saveBasic, settings);
ES3.StoreCachedFile(Config.GAME_PATH);
}
public void SaveGameByES3(bool saveRT = false)
{
var settings = new ES3Settings(Config.GAME_PATH, ES3.Location.Cache);
SaveGameBasic();
if (saveRT)
{
for (int i = 0; i < DataManager.Instance.randomThingsList.Count; i++)
{
var rt = DataManager.Instance.randomThingsList[i];
SaveRT(rt);
}
}
ES3.Save("SaveCourse", DataManager.Instance.courses, settings);
ES3.Save("SavePeople", DataManager.Instance.peopleList, settings);
ES3.Save("SaveProduct", DataManager.Instance.productList, settings);
ES3.Save("SaveMagic", DataManager.Instance.allMagicList, settings);
ES3.Save("SaveBuilding", DataManager.Instance.buildingList, settings);
ES3.StoreCachedFile(Config.GAME_PATH);
PlayerPrefs.SetInt(Config.GAME_SAVE_KAY, 1);
}
public void LoadGameByES3()
{
ES3.CacheFile(Config.GAME_PATH);
var settings = new ES3Settings(Config.GAME_PATH, ES3.Location.Cache);
saveBasic = ES3.Load<SaveBasicSO>("SaveBasic", settings);
if (saveBasic != null)
{
saveBasic.LoadData();
}
DataManager.Instance.courses = ES3.Load<List<CourseSO>>("SaveCourse", settings);
DataManager.Instance.randomThingsList = LoadRTList(DataManager.Instance.rtKeyList, settings);
DataManager.Instance.peopleList = ES3.Load<List<PeopleSO>>("SavePeople", settings);
DataManager.Instance.productList = ES3.Load<List<ProductSO>>("SaveProduct", settings);
DataManager.Instance.allMagicList = ES3.Load<List<MagicSO>>("SaveMagic", settings);
DataManager.Instance.buildingList = ES3.Load<List<BuildingSO>>("SaveBuilding", settings);
}
I also call SaveGameByES3 when unity function "OnApplicationPause" works on true.
when users start game, they will call the LoadGameByES3 function if Config.GAME_SAVE_KAY == 1, and some users meet the detail problem as next.
Code: Select all
Key "SaveBasic" was not found in this ES3File. Use Load<T>(key, defaultValue) if you want to return a default value if the key does not exist.