Cannot load data between different scenes

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Hisashi Joe
Posts: 6
Joined: Thu Apr 25, 2024 12:24 pm

Cannot load data between different scenes

Post by Hisashi Joe »

Hello,
I'm using a combination of Dialogue system, Playmaker, Ultimate Inventory System and Easy Save 3.
The save system has been setup to use Dialogue system saver instead of UIS as detailed in documentation.

In my first scene, the save button will start a Playmaker FSM state that has Dialogue System's Save Game action. It store result into a string variable called saveSlot.
Screenshot_13.png
Screenshot_13.png (19.1 KiB) Viewed 348 times
After that, the next FSM action us Easy Save's Save All action to store the saveSlot and other FSM variables into a file.
Screenshot_12.png
Screenshot_12.png (35.55 KiB) Viewed 348 times
When loading, I first start a Easy Save's Load All action to load all variables and then start Dialogue System's Load Game action to complete the loading.
Screenshot_11.png
Screenshot_11.png (23.25 KiB) Viewed 348 times
Screenshot_13.png
Screenshot_13.png (19.1 KiB) Viewed 348 times
The above process works fine when used in the first scene. But once player move into another scene with the same setup and make a save or do a load, I got a "NullReferenceException: Object reference not set to an instance of an object"

This error occurred during the Load All action state.
Screenshot_14.png
Screenshot_14.png (49.03 KiB) Viewed 348 times
Screenshot_15.png
Screenshot_15.png (22.29 KiB) Viewed 348 times
At this point, I have no idea what's happening.
I apologize if this sounds so confusing because I was also pretty confused trying to make the save system work across these 3 integrations.
Attachments
Screenshot_10.png
Screenshot_10.png (24.07 KiB) Viewed 348 times
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Cannot load data between different scenes

Post by Tony Li »

Hi,

Have you assigned any references in the inspector between the Dialogue Manager GameObject's hierarchy and GameObjects or FSMs outside of the Dialogue Manager GameObject's hierarchy?

If so, please see How To: Manage Player Controls and Scene Changes for a discussion of what's probably happening and some tips on how to resolve it. The context of that article is player controls and scene changes, but the same ideas apply to any type of scene change, including loading a saved game. (Loading a saved game closes the current scene and loads a new scene, even if that new scene is a fresh instance of the very same scene.)
Hisashi Joe
Posts: 6
Joined: Thu Apr 25, 2024 12:24 pm

Re: Cannot load data between different scenes

Post by Hisashi Joe »

Hi,

I double checked the scene and the Dialogue Manager GameObject and there isn't any reference to any GameObject outside of itself. There's one event FSM on Dialogue Manager GameObject that points to itself though.

But today, I replaced the Easy Save's Save All and Load All actions with Easy Save's Save Multiple and Load Multiple to control what variables it actually saved. And then it just works.

In Easy Save's documentation, it might be that the Load All action load all references in the scene including those that doesn't exist in another scene so it will throw error if the Load All action is triggered in a different scene than the one it was originally saved to. At least, that's my understanding so I decided to save variables individually despite it taking some time.

Also because I gave up trying to find which reference should exist and which should not.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Cannot load data between different scenes

Post by Tony Li »

Good catch!
Post Reply