Temporary hiding Dialogue UI if main menu is opened

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Esylin
Posts: 45
Joined: Thu Dec 16, 2021 1:21 am

Temporary hiding Dialogue UI if main menu is opened

Post by Esylin »

Hi, I have a pause menu for my game that pauses the game, if I try to open the pause menu in the middle of the conversation it looks weird because the dialogue UI does not hide. :cry:

I am wondering if it is possible to temporary hide the Dialogue UI in the middle of a conversation if i open my gameplay pause menu, then unhide the Dialogue UI if I close my pause menu?

I tried to use GameObject.SetActive toggle for the Dialogue UI canvas. It can close the Dialogue UI this way but it does not reopen after I close the pause menu with SetActive. :(

Please help! Thank you! :)
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Temporary hiding Dialogue UI if main menu is opened

Post by Tony Li »

Hi,

A simple way is to disable the Dialogue Manager's Canvas:

Code: Select all

DialogueManager.displaySettings.defaultCanvas.enabled = false;
Alternatively, you can use the SetDialoguePanel() sequencer command.

You may also want to pause the Dialogue System's input handling while the main menu is open. See:
How To: Pause Dialogue In Pause Menu
Esylin
Posts: 45
Joined: Thu Dec 16, 2021 1:21 am

Re: Temporary hiding Dialogue UI if main menu is opened

Post by Esylin »

Tony Li wrote: Fri Sep 15, 2023 7:59 am Hi,

A simple way is to disable the Dialogue Manager's Canvas:

Code: Select all

DialogueManager.displaySettings.defaultCanvas.enabled = false;
Alternatively, you can use the SetDialoguePanel() sequencer command.
Are there any way to execute this using PlayMaker instead of code? I tried to look for PlayMaker actions to start sequencer command but I can't find it. :(
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Temporary hiding Dialogue UI if main menu is opened

Post by Tony Li »

Hi,

You can put a PlayMaker FSM on the Dialogue Manager and configure it to disable the Canvas component.
Esylin
Posts: 45
Joined: Thu Dec 16, 2021 1:21 am

Re: Temporary hiding Dialogue UI if main menu is opened

Post by Esylin »

Actially, I think I found an alternative solution without needing to disable component or code at all.

I set a Canvas Group component for the Dialogue UI canvas, then change CanvasGroup.alpha to 0 on the Menu button .

However, now I run into a different issue.....

Since Dialogue manager has "Allow only one instance" and "Don't Destroy On Load", which is the default setting, all the Dialogue Manager in my scene files came from the Opening Main menu scene(the first scene after I launch the game).

So any component or alpha change that I made to the Dialogue UI Canvas won't work in that scene if I launch the game normally starting from the first scene.

What is the best solution to this problem? :?: Should I untick "Don't Destroy On Load" and put one Dialogue Manager in all scenes? I don't know if I would break Dialogue System like this. Or if there is a better solution for this? :?:
Esylin
Posts: 45
Joined: Thu Dec 16, 2021 1:21 am

Re: Temporary hiding Dialogue UI if main menu is opened

Post by Esylin »

Esylin wrote: Sun Sep 17, 2023 6:48 am Actially, I think I found an alternative solution without needing to disable component or code at all.

I set a Canvas Group component for the Dialogue UI canvas, then change CanvasGroup.alpha to 0 on the Menu button .

However, now I run into a different issue.....

Since Dialogue manager has "Allow only one instance" and "Don't Destroy On Load", which is the default setting, all the Dialogue Manager in my scene files came from the Opening Main menu scene(the first scene after I launch the game).

So any component or alpha change that I made to the Dialogue UI Canvas won't work in that scene if I launch the game normally starting from the first scene.

What is the best solution to this problem? :?: Should I untick "Don't Destroy On Load" and put one Dialogue Manager in all scenes? I don't know if I would break Dialogue System like this. Or if there is a better solution for this? :?:
Update: I think I found another solution without needing to change Dialogue manager "Don't Destroy On Load". I set the Canvas Group on the Dialogue Panel prefab instead, then change CanvasGroup.alpha to 0 using Playmaker global variable if the main menu is on.

I don't know if this method will have a different bug though. If there are no other easier solution I'll stick with it. :)
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Temporary hiding Dialogue UI if main menu is opened

Post by Tony Li »

If that works, use it. I recommend keeping Don't Destroy On Load ticked.
Esylin
Posts: 45
Joined: Thu Dec 16, 2021 1:21 am

Re: Temporary hiding Dialogue UI if main menu is opened

Post by Esylin »

Tony Li wrote: Sun Sep 17, 2023 8:44 am If that works, use it. I recommend keeping Don't Destroy On Load ticked.
Got it, thanks for the advice! :)
Post Reply