Page 1 of 1

Having trouble getting stuff to work between scenes

Posted: Wed Aug 18, 2021 2:36 am
by datchcole
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:

Code: Select all

NullReferenceException: Object reference not set to an instance of an object
mandatoryCathedralForcer.Update () (at Assets/Scripts/mandatoryCathedralForcer.cs:51)
Also here is what I use for saving and loading Dialogue System variables, which saves in its own scene but not across scenes.

Code: Select all

s = SaveSystem.Serialize(SaveSystem.RecordSavedGameData());
ES3.Save("dialogueState" , s);

Code: Select all

PersistentDataManager.ApplySaveData (ES3.Load<string> ("dialogue"));
Also here is my general save code:

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);

		
	}
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!

Re: Having trouble getting stuff to work between scenes

Posted: Wed Aug 18, 2021 4:55 am
by datchcole
Actually disregard the NullReferenceException Error part of my question. I haven't quite figured out what's responsible for that (my scene load spawns two fpsControllers as well among other things...somehow). I'm not sure if it's Easy Save related. But I would still very much want more guidance about saving and loading between scenes.

Re: Having trouble getting stuff to work between scenes

Posted: Wed Aug 18, 2021 7:46 am
by Joel
Hi there,

Please could you separate out this line:

Code: Select all

PersistentDataManager.ApplySaveData (ES3.Load<string> ("dialogue"));
Into this and let me know what it outputs to console:

Code: Select all

var str = ES3.Load<string> ("dialogue");
Debug.Log(str);
PersistentDataManager.ApplySaveData (str);
All the best,
Joel

Re: Having trouble getting stuff to work between scenes

Posted: Thu Aug 19, 2021 4:04 am
by datchcole
Here's what I get (sorry I have a lot of variables haha):

Code: Select all

Variable={Alert="", givenUpstairsKey=false, PreviouslySelected=false, PreviouslySelectedNameBig=false, PreviouslySelectedServantBig=false, PreviouslySelectedMeaningtBig=false, PreviouslySelectedStationBig=false, bigBlueHaventMet=true, askedOneBigBlueQuestion=false, bigBlueTalkedtoothpick=false, bigBlueinBreakRoom=false, bigBlueSelectedGoThrough=false, metToothpick=false, metBlueFirst=false, breakroomResolved=false, blockPermissionGiven=false, givenBreakroomQuest=false, blueDisableFirstMeeting=false, blueDisableSecondMeeting=false, curiousLooping=true, curiousFirstPass=false, curiousGone=false, confusedGone=false, hyperGone=false, pinkEnterCombat=false, defeatedPink=false, toothPassthrough=false, toothDontNeedToTell=false, toothGivenBlockQuest=false, givenBlockObject=false, toothBackroomPermission=false, toothFinishedDialogue=false, toothBigBlueAsked=false, toothBlueAsked=false, toothDupeAsked=false, toothWhereAreWe=false, toothWhatAreYou=false, toothWhatAreThese=false, toothNoThanks=false, netielFirstConvoFinish=false, bigChapelQuestAsked=false, bigSecondConvoStarted=false, bigBossQuest=false, bigFrontDeskQuest=false, toothDoneTalking=false, bigToothStarted=false, chapelPermission=false, askedChapel=false, toothAskedOutFirst=false, toothLooksLikeYou=false, officeKeyGet=false, BigObserverRemarked=false, toothOffended=false, toothLookedLikeYou=false, tookDownPainting=false, finishedOilObConvo=false, paintingPermission=false, oilPermission=false, haveOil=false, canStand=false, servedMult=false, askedPrimo=false, askedMother=false, lobbyDatchDone=false, lobbyObsDone=false, toothEavesdropped=false, prayer2Done=false, prayer1Done=false, treeObDone=false, playfulDone=false, statueDone=false, lobbyObDone=false, paintingObDone=false, toothOBDone=false, checkDatchDone2=false, prayStairDone=false, gradStairDone=false, bronzeDone=false, bigThink=false, bigGesture=false, netTalk=false, netThink=false, netShadowAsked=false, blueTalk=false, blueGesture=false, lobbyDatchDone2=false, papersDone=false, computerDatchDone=false, toothGesture=false, toothTalk=false, toothFace=false, Actor="", Conversant="", ActorIndex="", ConversantIndex=""};
Actor={Player={Name="Player", Pictures="[]", Description="oooh It you!", IsPlayer=true}, Toothpick={Name="Toothpick", Pictures="[]", Description="Animate doll of an entity far away, loves to mess with player", IsPlayer=false}, Blue={Name="Blue", Pictures="[]", Description="Serves the Amalgamate, forced to tolerate Toothpick", IsPlayer=false}, Pink={Name="Pink", Pictures="[]", Description="Loyal, crazed servant of Toothpick", IsPlayer=false}, Big_Blue={Name="Big Blue", Pictures="[]", Description="Chill servant. Not very smart, but one of the kindest residents of the towers.", IsPlayer=false}, Dupe={Name="Dupe", Pictures="[]", Description="Pale Pink Servant whose lost their mind for the most part", IsPlayer=false}, ObserverCurious={Name="ObserverCurious", Pictures="[]", Description="", IsPlayer=false}, ObserverConfused={Name="ObserverConfused", Pictures="[]", Description="", IsPlayer=false}, ObserverHyper={Name="ObserverHyper", Pictures="[]", Description="", IsPlayer=false}, Netiel={Name="Netiel", Pictures="[]", Description="Amalgamate angel", IsPlayer=false}, ObserverChapel={Name="ObserverChapel", Pictures="[]", Description="", IsPlayer=false}, ChilllinServant={Name="ChilllinServant", Pictures="[]", Description="", IsPlayer=false}, observerOil={Name="observerOil", Pictures="[]", Description="", IsPlayer=false}, Needs_Oil={Name="Needs Oil", Pictures="[]", Description="", IsPlayer=false}, noPortrait={Name="noPortrait", Pictures="[]", Description="", IsPlayer=false}, Gradient_Datch={Name="Gradient Datch", Pictures="[]", Description="", IsPlayer=false}, Checkered_Datch={Name="Checkered Datch", Pictures="[]", Description="", IsPlayer=false}, ["???"]={Name="???", Pictures="[]", Description="", IsPlayer=false}, Bronze={Name="Bronze", Pictures="[]", Description="", IsPlayer=false}, Praying_Amalgamate={Name="Praying Amalgamate", Pictures="[]", Description="", IsPlayer=false}, Observer={Name="Observer", Pictures="[]", Description="", IsPlayer=false}}; StatusTable = ""; RelationshipTable = ""; 
I also found out the other issue I was having was from Easy Save. Clearing the persistent data path fixed it for now. I probably caused the issue trying to save and load between scenes, so I just need to figure out how to do it properly 🤔

Re: Having trouble getting stuff to work between scenes

Posted: Thu Aug 19, 2021 7:31 am
by Joel
Hi there,

This indicates that Easy Save is saving and loading the data correctly, so the issue will be with the serializer you are using (which unfortunately we cannot assist with).

All the best,
Joel

Re: Having trouble getting stuff to work between scenes

Posted: Fri Aug 20, 2021 3:01 am
by datchcole
Gotcha. I'll keep working on it. Thank you for your help.