Having trouble getting stuff to work between scenes
Posted: Wed Aug 18, 2021 2:36 am
I finally got save and load to work great in one scene, but as soon as I try to save and load across scenes I run into trouble. I was having a problem with a variable from the Dialogue Manager asset from the Unity store not saving a bool variable value across scenes, but now I also get the error if I save and then try to switch scenes:
Also here is what I use for saving and loading Dialogue System variables, which saves in its own scene but not across scenes.
Also here is my general save code:
I've attached my script that's giving me the error as well. Please let me know if I need to include any more info. Thank you for any advice!
Code: Select all
NullReferenceException: Object reference not set to an instance of an object
mandatoryCathedralForcer.Update () (at Assets/Scripts/mandatoryCathedralForcer.cs:51)
Code: Select all
s = SaveSystem.Serialize(SaveSystem.RecordSavedGameData());
ES3.Save("dialogueState" , s);
Code: Select all
PersistentDataManager.ApplySaveData (ES3.Load<string> ("dialogue"));
Code: Select all
public void Save(){
ES3.Save(SceneManager.GetActiveScene().name, "savedScene");
ES3.Save( "playerPosition", player.transform.position);
ES3.Save("inventory", player.GetComponent<inventoryManager>().inventoryArray);
ES3AutoSaveMgr.Current.Save();
//save current dialogue system state//
s = SaveSystem.Serialize(SaveSystem.RecordSavedGameData());
ES3.Save("dialogueState" , s);
ES3.Save<string> ("dialogue", PersistentDataManager.GetSaveData ());
///////
notifyImage.SetActive(true);
notifyImage.GetComponent<Animator>().SetBool("isFading", true);
pauseMenu.SetActive(false);
}