Alert Message Box in Middle of Conversation

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
colorbar
Posts: 12
Joined: Sun Apr 30, 2023 10:35 pm

Alert Message Box in Middle of Conversation

Post by colorbar »

Hi there,

I'm new to be Unity and also this dialogue system, but am really loving it so far and feel like I've already saved a ton of time by using it.

I have a moment in the game that is kind of a turning point. The NPC has just explained their situation and I'd like the dialogue UI to go away, and have an alert message pop up in the middle of the screen that says "Will you help him?" and have Yes or No buttons with a timer. Then from there a cut scene will start.

Is this something that is fairly easy to do?

Any help I can get would be much appreciated.
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: Alert Message Box in Middle of Conversation

Post by Tony Li »

Hi,

Thanks for using the Dialogue System!

If you just wanted to show a non-interactive alert, you could do this:

1. Inspect the Dialogue Manager GameObject, and tick Display Settings > Alert Settings > Allow Alerts During Conversations.

2. Add a dialogue entry node after the turning point. Leave the dialogue text blank. Set the Script field to something like:

Code: Select all

ShowAlert("Your alert message here.")
Set the Sequence field to something like:

Code: Select all

SetDialoguePanel(false);
SetDialoguePanel(true)@4
or whatever duration the alert message lasts for.

---

However, since you want to ask Yes/No, there are two ways you could approach it:

1. It sounds like it happens at the end of the conversation since, after answering Yes or No, it starts a cutscene instead of continuing the conversation. If this is the case, you could write your own Yes/No box and run it at the end of the conversation.

2. But another way to do it is in the conversation itself, using an additional subtitle panel and response menu panel configured only for Yes/No questions. To do this:
  • Duplicate one of the existing subtitle panels, style it to look the way you want, and add it to the dialogue UI's Standard Dialogue UI component > Conversation UI Elements > Subtitle Panels list. Make a note of its element number (e.g., 2).
  • Do the same to create a new response menu panel, and note its element number.
  • In the dialogue entry node before the question, set the Sequence to:

    Code: Select all

    {{default}};
    SetPanel(NPC, 2);
    SetMenuPanel(Player, 1)
  • After that node, add a node for the question. Set its Sequence to:

    Code: Select all

    SetTimeout(5)
  • Add Yes and No player response nodes after that. Set their Sequence fields to:

    Code: Select all

    {{default}};
    SetPanel(NPC, 0);
    SetMenuPanel(Player, 0)
A few notes:
  • In the SetPanel() sequencer commands, use the NPC actor's name in place of "NPC".
  • In the SetTimeout() sequencer command, specify the timeout duration in seconds (e.g., 5 seconds in the example above).
  • In the example scene below, I set the Dialogue Manager's Input Settings > Response Timeout Action to "Choose Last Response" so it will choose No by default.
DS_YesNoBoxExample_2023-04-30.unitypackage
colorbar
Posts: 12
Joined: Sun Apr 30, 2023 10:35 pm

Re: Alert Message Box in Middle of Conversation

Post by colorbar »

Thanks so much! I probably won't be able to test this out tonight, but I'll let you know how it goes when I do. Again thanks for the help and quick response!
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: Alert Message Box in Middle of Conversation

Post by Tony Li »

Happy to help!
rmagn
Posts: 21
Joined: Tue Jul 09, 2024 6:05 am

Re: Alert Message Box in Middle of Conversation

Post by rmagn »

hi,
sorry for bringing old thread up, but my case is about the same as the non interactive alert
i have this sequence

Code: Select all

SetDialoguePanel(false);
Continue()@3;
SetDialoguePanel(true)@3;
which worked fine but at the start of the sequence, it displayed the dialogue panel for a little moment before it started the sequence and show the alert, like this video

1.)how can i fix it so dialogue panel won't show up at all when using that sequence?
2.) is it possible to also insert dialogue text with alert in 1 node and play dialogue first, wait until continue button, then show the alert just using 1 node? or is it better to separate dialogue text with alert text into 2 nodes?
i tried set using this

Code: Select all

{{default}}; //-> default = Delay({{end}})
SetDialoguePanel(false);
Continue()@3;
SetDialoguePanel(true)@3;
but it didnt show the dialogue text, only the alert text
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: Alert Message Box in Middle of Conversation

Post by Tony Li »

Hi,
rmagn wrote: Tue Jul 16, 2024 5:18 am1.)how can i fix it so dialogue panel won't show up at all when using that sequence?
Use SetDialoguePanel(false,immediate)
rmagn wrote: Tue Jul 16, 2024 5:18 am2.) is it possible to also insert dialogue text with alert in 1 node and play dialogue first, wait until continue button, then show the alert just using 1 node? or is it better to separate dialogue text with alert text into 2 nodes?
Either is fine. Use two nodes if it makes the order of event clearer. For one node, use the Script field to set Variable["Alert"] and call ShowAlert() in the Sequence field when the player continues:
  • Script: Variable["Alert"] = "This is an alert message."
  • Sequence: ShowAlert()@Message(Continued)
rmagn
Posts: 21
Joined: Tue Jul 09, 2024 6:05 am

Re: Alert Message Box in Middle of Conversation

Post by rmagn »

SetDialoguePanel(false,immediate)
This works for the 2 nodes, thank you !
Script: Variable["Alert"] = "This is an alert message."
Sequence: ShowAlert()@Message(Continued)
This works too, but it instantly end the conversation (regain character control) after showing the alert. i tried adding delay(3) below the showalert() but it doesnt work? how can i show the alert for 3second before ending conversation?
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: Alert Message Box in Middle of Conversation

Post by Tony Li »

Hi,

Add an empty node at the end (or whenever you want to delay). Leave the Dialogue Text blank, and set the Sequence field to one of these:

If you want to delay, and the conversation doesn't normally require the player to click a continue button:

Code: Select all

Delay(3)
If the player normally has to click a continue button, use this instead to simulate a continue button click after 3 seconds:

Code: Select all

Continue()@3
If you also need to hide and then show the dialogue UI, use something like:

Code: Select all

SetDialoguePanel(false);
SetDialoguePanel(true)@3
or:

Code: Select all

SetDialoguePanel(false);
required SetDialoguePanel(true)@3;
Continue()@3
Post Reply