1 of these I use to store a list in the editor of key/value pairs which then, on Load, it copies these to a dictionary (startinggamestates to gamestatedictionary) which the mission system then checks to see if it a value has been changed to give/complete/fail a mission.
The odd issue is, no matter what I try (ES3, custom system or other) I just can't get that thing to change the values on load.
I check the save files and they are there fine. it lists them and the correct values. However on load, it runs the load but the values do not change.
I even put the es3load in a method and on start set a 20f invoke delay just to make sure all the new scene resets are finished. Then a 5sec delay to loop through and debug the values out. (I know these times are excessive, they are of course only there for testing)
The onstate.change is a custom method that gets called whenever a value is changed.
Code: Select all
private void Start()
{
Invoke("LoadAppMan", 20f);
}
private void LoadAppMan()
{
if (ES3.KeyExists("gamestatedictionarySaveKey"))
{
Debug.Log("I loaded the es3 save values");
_gameStateDictionary = ES3.Load("gamestatedictionarySaveKey", _gameStateDictionary);
}
Invoke("DictionaryTest", 5f);
}
void DictionaryTest()
{
OnStateChanged.Invoke();
foreach (var element in _gameStateDictionary)
{
Debug.LogFormat("Done Loaded: Dictionary is now reading: (Key = {0},Value = {1})", element.Key, element.Value);
}
}
}
private void OnApplicationQuit()
{
ES3.Save("gamestatedictionarySaveKey", _gameStateDictionary);
}