Page 1 of 1

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

Posted: Wed May 01, 2019 12:19 pm
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.

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

Posted: Wed May 01, 2019 4:47 pm
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.

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

Posted: Fri May 03, 2019 5:09 am
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.

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

Posted: Fri May 03, 2019 5:49 am
by Afello
###Post deleted, no longer relevant###

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

Posted: Fri May 03, 2019 6:30 am
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!!!

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

Posted: Fri May 03, 2019 8:21 am
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;
    }
}