Dialogue System "not working/showing" when switching from scenes

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Afello
Posts: 13
Joined: Sat Mar 02, 2019 12:34 pm

Dialogue System "not working/showing" when switching from scenes

Post by Afello »

Hi!

I created a bunch of small gameplay prototypes, each containing one or more conversations. From my main menu I can choose a prototype and start playing. The first time I do this everything works fine and the conversations start and work as expected. But when I hit the pause menu and choose "return to main menu" (which loads the main menu) and choose a different prototype, none of the conversations start. When I check debug mode on the DialogueManager I get no warnings or errors. I do see it starts the conversation but it doesn't visualise on screen nor does the conversation seem to continue in the console messages (if an npc is speaking through various nodes).

I tried various set ups, right now I create the DialogueManager in the main menu and use 'don't destroy on load' but get the same results when I would give each prototype it's own DialogueManager without 'don't destroy on load' activated.
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System "not working/showing" when switching from scenes

Post by Tony Li »

What mechanism do you use to start conversations? Dialogue System Trigger? UI button?

Is it possible that references to other GameObjects are getting lost when changing scenes? This often happens when a Don't Destroy On Load GameObject has a reference to a non-Don't Destroy On Load GameObject or vice-versa.
Afello
Posts: 13
Joined: Sat Mar 02, 2019 12:34 pm

Re: Dialogue System "not working/showing" when switching from scenes

Post by Afello »

I am using Playmaker to start and stop conversations. The only other object that is marked as 'Don't destroy on load' is the GameManager from the Corgi Engine but that manages frame rate and sound settings so not sure if this would conflict with the DialogueManager?

I don't believe the DialogueManager loses any references to objects that get lost. Only reference the dialogue manager needs is to the UI that it spawns into itself on start.
Last edited by Afello on Fri May 03, 2019 6:24 am, edited 1 time in total.
Afello
Posts: 13
Joined: Sat Mar 02, 2019 12:34 pm

Re: Dialogue System "not working/showing" when switching from scenes

Post by Afello »

###Post deleted, no longer relevant###
Last edited by Afello on Fri May 03, 2019 7:08 am, edited 2 times in total.
Afello
Posts: 13
Joined: Sat Mar 02, 2019 12:34 pm

Re: Dialogue System "not working/showing" when switching from scenes

Post by Afello »

Okay, I found a way to get the dialog back on screen after switching scenes. If I go to the pause menu and continue playing the scene instead of exiting, the Dialog UI "magically" reappears on screen! Which made me realise I turn the Dialog UI invisible when entering pause and turn it back on when exiting pause (because I have a semi transparant pause menu and don't like the noise of subtitle text etc in the background). But if I switch scenes I never give the turn UI visible command... so okay, quite stupid of me :oops:

Now I just need to find a way to fix this but thanks for thinking along and trying to help!!!
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System "not working/showing" when switching from scenes

Post by Tony Li »

Glad you got to the bottom of it. If you're making it invisible by disabling the Dialogue Manager's Canvas component, you could add a script like this that re-enables it whenever a new scene is loaded. Add it to the Canvas.

EnableCanvasOnSceneLoad.cs

Code: Select all

using UnityEngine;
using UnityEngine.SceneManagement;

public class EnableCanvasOnSceneLoad : MonoBehaviour
{
    void OnEnable() { SceneManager.sceneLoaded += OnSceneLoaded; }
    void OnDisable() { SceneManager.sceneLoaded -= OnSceneLoaded; }
    
    void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        GetComponent<Canvas>().enabled = true;
    }
}
Post Reply