Page 1 of 1

Exception: Key "SaveBasic" was not found in this ES3File

Posted: Mon Nov 08, 2021 9:17 am
by tzwyf
Hello!

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);
        }
SaveGameBasic only save some basic data and is always called.SaveGameByES3 is called when some options are done on otehr SOs.
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.
So, i hope for your advice!

Re: Exception: Key "SaveBasic" was not found in this ES3File

Posted: Mon Nov 08, 2021 9:26 am
by tzwyf
Unity version: 2020.3.9f1c1
bug phone modle: Xiaomi mix4, onePlus7 pro, and some HuaWei phone(tel-an10,Mate40,mate30 Pro) maybe HarmonyOS system

Re: Exception: Key "SaveBasic" was not found in this ES3File

Posted: Mon Nov 08, 2021 1:02 pm
by Joel
Hi there,

We've had no other reports of this.

If Easy Save encounters an issue when creating a file then it will throw an IO exception. As you don't appear to be getting this, this indicates that either the code to save the data isn't being called (which would be an issue with your logic or Unity), there is an issue with the device or OS, or the user has removed the file themselves.

I'd also recommend ensuring that you're using the latest version of Easy Save, if you're not already.

All the best,
Joel

Re: Exception: Key "SaveBasic" was not found in this ES3File

Posted: Tue Nov 09, 2021 6:08 am
by tzwyf
OK,thanks for your advice.

Re: Exception: Key "SaveBasic" was not found in this ES3File

Posted: Thu Nov 11, 2021 3:45 am
by tzwyf
After a few days of testing, this problem is most likely caused by that I save game data in OnApplicationPause(true).If user quit game fast so that the data file is saving on .es3.tmp format and to late to be saved by .es3 format. When users load game next time, they will not find the key in .es3.tmp file.

So far,no users feedback the problem of stuck in loading scene after I remove the save code in OnApplicationPause(true).

Re: Exception: Key "SaveBasic" was not found in this ES3File

Posted: Thu Nov 11, 2021 7:54 am
by Joel
Hi there,

Thanks for the info. If you’re able to replicate this then I recommend reporting it to Unity, as OnApplicationPause should block until execution is complete. If certain devices are stopping execution early then this is something Unity would want to be aware of.

All the best,
Joel