[Issue] Scene Events not working after reentering scene

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
BitorVarbosa
Posts: 6
Joined: Fri Aug 04, 2023 11:20 am

[Issue] Scene Events not working after reentering scene

Post by BitorVarbosa »

Hi there!

We are using the Dialogue System version 2.2.40.
Unity version 2021.3.23f1

Before I explain the issue, I have to say that I found a "solution" but it required me to edit the asset's code while investigating the problem, so I'm wondering if I'm doing something wrong.

Setup:

In our project, we have a scene called Main, which contains the DialogueManager, the Main Camera, the game's UI and other Managers.

Whenever we need to load a map, a manager inside the Main scene loads the scene additively, so usually there are 2 scenes open at the same time, for example, the Main scene and the Map_School scene.

Inside each Map scene, there's the DialogueSystemSceneEvents object that contains the events for that scene, it always stays there at the root of the Map scene, so when we exit the Map and change scenes, the object is destroyed along with the scene we just left.

The Issue:

When we exit a scene and later go back to that same scene, the scene events (yellow stars in the nodes) no longer work.

>Map_A has a dialogue with a event scene node, it works
https://prnt.sc/s_SbpCWSYdWV
>We exit the scene to Map_B
>We take a door from Map_B back to Map_A
>Scene event (yellow star) no longer works

What "fixed" the issue:

Like I said in the beginning, I did something that might have fixed the issue on our end but I can't help but wondering if I broke something.

I opened up the DialogueSystemSceneEvents.cs script and right after the Awake() function, I just added the lines:

Code: Select all

void OnDisable()
        {
            m_sceneInstances.Remove(this);
        }
And the problem is gone.
But it doesn't make sense why :/
I tried adding a Debug.Log to the Awake() function to check if the problem has something to do with not adding the object to list the second time (because the list is static), but with or without my modification it logs just normally, it adds the object again to the list, but the scene event calls only work with that OnDisable() function above.

Maybe the list ends up having 2 entries with the same ID?

Anyway, I wanted to bring this up to ask if I'm doing something wrong.

Thank you in advance.
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: [Issue] Scene Events not working after reentering scene

Post by Tony Li »

Hi,

The Dialogue System Extras page has a patch for 2.2.40 - 2.2.40.2. You don't have to edit any code; just import the patch. This fix is also in 2.240.3, which should be available for download in the next day or two.
BitorVarbosa
Posts: 6
Joined: Fri Aug 04, 2023 11:20 am

Re: [Issue] Scene Events not working after reentering scene

Post by BitorVarbosa »

Thanks! It fixed the issue.
I didn't know about those patches. I'll keep an eye there for now on.
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: [Issue] Scene Events not working after reentering scene

Post by Tony Li »

Glad to help! Version 2.2.40.3 is out now, so no need for patches for this issue.
Post Reply