On Scene Reload, Some Scene Events Not Working

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
GiantDad
Posts: 3
Joined: Fri Apr 19, 2024 2:08 am

On Scene Reload, Some Scene Events Not Working

Post by GiantDad »

Hello! I'm loving the dialogue system so far, but I'm having a problem with my dialogue scene events that I just cannot figure out no matter how much I investigate. Any help is greatly appreciated.

When I Save and Load my scene, The conversation states and dialogue variables load beautifully!
Everything seems to be working perfectly on reload except that about a quarter of my scene events are not being triggered by the dialogue. These events, otherwise, work perfectly if the scene is not reloaded.

I made sure to not use any scene-persisting GameObjects for the scene events so as to not lose any references.
I can not see a reason or a pattern for it. The events that get skipped seem to be totally random. Even when calling on the exact same scene reference, some events get called and some do not.
The only notable detail that I managed to notice is that it is not individual events that were skipped but that all events called on some individual dialogue nodes get skipped.

I'll try to add any info I can think of:

I am using Unity 2022.3.25 and I have just updated the Dialogue System to 2.2.4.5(and unfortunately, the problem persists!).

I am using Easy Save 3 to save and load the dialogue's data.

C# Saving code:

Code: Select all

ES3.Save("Dialogue", SaveSystem.Serialize(SaveSystem.RecordSavedGameData()), _saveFile);
ES3.Save("PlayerConvo", _playerDialogueController.Conversation(), _saveFile);
ES3.Save("SigridConvo", _sigridNPC.Conversation(), _saveFile);
//ES3.Save("DialoguePer", PersistentDataManager.GetSaveData(), _saveFile); 
C# Loading code:

Code: Select all

SaveSystem.ApplySavedGameData(SaveSystem.Deserialize<SavedGameData>(ES3.Load<string>("Dialogue", _saveFile)));
_playerDialogueController.SetConvo(ES3.Load<string>("PlayerConvo", _saveFile));
_sigridNPC.SetConversation(ES3.Load<string>("SigridConvo", _saveFile));
//PersistentDataManager.ApplySaveData(ES3.Load<string>("DialoguePer", _saveFile));
I have commented out the last line of the code as I was testing if maybe I was just saving using the wrong method. From what I could tell, both ways worked the same.

I'm sure I'm probably just missing something obvious but it's driving me crazy! Thanks for taking the time to read this. Have a good one!
Attachments
Desktop Screenshot 2024.04.18 - 23.35.43.79.png
Desktop Screenshot 2024.04.18 - 23.35.43.79.png (164.81 KiB) Viewed 242 times
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: On Scene Reload, Some Scene Events Not Working

Post by Tony Li »

Hi,

Fortunately, scene events are fairly easy to diagnose.

Inspect your scene event in the Dialogue Editor. It will have a unique GUID value:

sceneEvent1.png
sceneEvent1.png (64.74 KiB) Viewed 240 times

Then open the scene where that event is defined, locate scene's "Dialogue System Scene Events" GameObject, and confirm that there's an entry with the same GUID:

sceneEvent2.png
sceneEvent2.png (55.52 KiB) Viewed 240 times

Each scene should have only one "Dialogue System Scene Events" GameObject.

At runtime, the dialogue entry will examine all "Dialogue System Scene Events" GameObjects in all loaded scenes for an entry with the matching GUID. (Since Unity allows you to additively load scenes, it's possible to have more than one scene loaded at a time, so there may be more than one "Dialogue System Scene Events" GameObject.) If it finds the entry, it will run the event.

Also, please make sure you're using a recent version of the Dialogue System (2.2.41+).

The most common culprits are that the wrong scene is loaded (i.e., without a "Dialogue System Scene Events" GameObject with a matching GUID) or for some reason the GUIDs no longer match between the dialogue entry and the "Dialogue System Scene Events".
GiantDad
Posts: 3
Joined: Fri Apr 19, 2024 2:08 am

Re: On Scene Reload, Some Scene Events Not Working

Post by GiantDad »

Hi Tony,

Wow, such a speedy and detailed response! Thank you so much!

I've checked over the areas that you pointed out and I don't seem to be having any of the common problems you have listed, but I may just be missing something.

I inspected and compared the GUIDs in the Dialogue Editor and in the "Dialogue System Scene Events" GameObject. I did this outside of runtime, during runtime (before I reloaded - while it works), and during runtime (after I reloaded - When the issue is taking place).
In all three checks, the GUIDs matched and the references were unbroken so I seem to be good there.

During runtime, after reload, I checked for multiple "Dialogue System Scene Events" GameObjects and have confirmed that there is only the one.

I am currently working in a single scene and am reloading my scene in "single" mode so I should not have any scenes running additively.
I do, however, have a "Do Not Destroy on Load" scene that runs at the same time. I do not have a "Dialogue System Scene Events" GameObject in this either, though, so I don't believe the problem could stem from there.

For the Dialogue System version, I updated to the newest version last night using unity's Package Manager. This didn't fix the problem but I did notice something that I maybe should've looked deeper into:

After I updated the Dialogue System in the package manager and went to import, I noticed that every component That I saw was deselected (and not selectable). I did not scroll down all the way on the import page so I can't say for sure that nothing was imported, but it did concern me a bit.

Should I be removing the old version of the dialogue system before I import the updated version? Would doing this cause me to lose the data stored in the Dialogue database?

Thank you again for your help, Tony. I haven't been this stumped by something in a long time. Hope your day is going great!
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: On Scene Reload, Some Scene Events Not Working

Post by Tony Li »

Hi,

It sounds like you're doing everything perfectly. Only a few files typically change between versions, so it's fine if most of the files were unticked when you imported the current version. Unless the release notes say otherwise (which has only happened twice in the Dialogue System's ten years of development), you can import new versions on top of the existing installation.

Here's a debug package:

DS_SceneEventsDebugVersion_2024-04-19.unitypackage

If a scene event is working correctly, you'll see something like this in the Console:

Code: Select all

DEBUG: GetDialogueEntrySceneEvent(88398b51-f11e-4434-bee9-b4a681a1b46f) will check 1 DialogueSystemSceneEvents components for the GUID...
DEBUG: GetDialogueEntrySceneEvent(88398b51-f11e-4434-bee9-b4a681a1b46f) found the event.
and you can click on the second line to highlight the DialogueSystemSceneEvents GameObject in the Hierarchy view.

If it fails, you'll see something like:

Code: Select all

DEBUG: GetDialogueEntrySceneEvent(88398b51-f11e-4434-bee9-b4a681a1b46f) didn't find a DialogueSystemSceneEvents component with the specified GUID.
GiantDad
Posts: 3
Joined: Fri Apr 19, 2024 2:08 am

Re: On Scene Reload, Some Scene Events Not Working

Post by GiantDad »

Tony! Thank you so much! My mind is finally free! The problem is solved!

As embarrassing as it is to say, it seems like the problem came from my own code.

After I used the debugger you sent (and all events were successful in the logs), I knew to look elsewhere.

After a bit of debugging, I found that I had a "true" parameter missing from a couple of my "GetCompontentInChildren" functions. So when my own "SceneEventHandler" and "NPC" classes tried to re-reference some persistent classes on reload, they returned null(as they were inactive at the time).

The strange thing is, I had absolutely no null reference logs appear in my console, so I wrote off the possibility. I'm glad I was driven to look into it further!

I'm sorry to have wasted your time with something that ended up being totally unrelated to your Software. I will say that without your help in narrowing down the problem, I would probably still be messing with the dialogue and save system. Who knows when I would have realized the true problem so, thanks!

I hope you have a fantastic day and I look forward to using your awesome dialogue system in all of my projects!
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: On Scene Reload, Some Scene Events Not Working

Post by Tony Li »

Hi,

Glad to help! If you're using version control, you can revert that debug file. Otherwise you can import it from version 2.2.45 in the Package Manager window.
Post Reply