How turn off auto-advance on subtitle-dialogs?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Hulda_Gnodima
Posts: 19
Joined: Fri Jan 17, 2020 9:04 am

How turn off auto-advance on subtitle-dialogs?

Post by Hulda_Gnodima »

Hello again!

I'm a new user to this asset, and I already love it!

I have another question about how to turn off the auto-advancing dialog. I followed this tutorial:


My dialog however is behaving differently to the one in the tutorial. My dialog advances automatically when I don't click anything and the continue button is not appearing during the conversations. I would like conversations to advance only on confirmation-clicks. I've looked at the documentation/some more of your tutorials but couldn't find this specific information.

Specifically I would like each subtitle-dialog-text to only advance to the next dialog-text if the player presses the continue-button or the key "E" or something similar. Is there an easy way for me to achieve this?

Thanks so much in advance!
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: How turn off auto-advance on subtitle-dialogs?

Post by Tony Li »

Hi,

Thanks for using the Dialogue System!

Inspect the Dialogue Manager GameObject. Set the Display Settings > Subtitle Settings > Continue Button dropdown to Always. This will always show the continue button with every subtitle and wait for it to be clicked.

If you want to map a hotkey (e.g., "E") to the continue button, locate it in the dialogue UI and add a UI Button Key Trigger component.
User avatar
Hulda_Gnodima
Posts: 19
Joined: Fri Jan 17, 2020 9:04 am

Re: How turn off auto-advance on subtitle-dialogs?

Post by Hulda_Gnodima »

Thank you very much for your super-quick reply! That did the trick for me :D
User avatar
Hulda_Gnodima
Posts: 19
Joined: Fri Jan 17, 2020 9:04 am

Re: How turn off auto-advance on subtitle-dialogs?

Post by Hulda_Gnodima »

Tony Li wrote: Fri Jan 17, 2020 8:41 pm Hi,

Thanks for using the Dialogue System!

Inspect the Dialogue Manager GameObject. Set the Display Settings > Subtitle Settings > Continue Button dropdown to Always. This will always show the continue button with every subtitle and wait for it to be clicked.

If you want to map a hotkey (e.g., "E") to the continue button, locate it in the dialogue UI and add a UI Button Key Trigger component.
I have some follow-up questions after following your instructions. Thank you for being so helpful.

The continue-button now always displays, and upon a key-press of the "UI Button Key Trigger" specified text continues.
Some strange behaviors are happening for me however, they are described in detail below with a video:

Strange behaviours/Questions:
The full sequence of the dialog can be seen 00:00-00:30 in the video:


1. Unclickable Button
The continue-button isn't clickable at all if I don't have the "UI Button Key Trigger" assigned to it. Is this intended behaviour? If I have it assigned, the button clicks when I press anywhere on the screen (which is what I want), but I was wondering if the button cannot become specifically clickable (as in the player has to press the button with the mouse directly, like regular Unity UI buttons)?
(see 00:32-00:52 in the video)

2. Fast forwarding not working on NPC
When I add the "UI Button Key Trigger" the button clicks when pressing the key assigned to it. However, the continue-button will only on first click "fast-forward" and on the second click "continue" on the PC's dialog-text-box. If the continue-button is pressed on an NPC's dialog-texts, the entire current dialog-text just "skips" to the next dialog-text. That is to say, the button isn't fast forwarding the dialog-text, it's just skipping it on any of the NPC's dialog-texts. Do you know what could be wrong? The continue-button-referenced object is the same on PC and NPC subtitle panels.
(see 00:60-01:14 in the video).

3. Any key-press to advance convo?
Is there any way to choose "Any keyboard key" via the "UI Button Key Trigger", meaning any click on the keyboard/mouse will fast forward/continue the the dialog-text? I cannot find such a choice in the drop-down menu.

4. Flickering Selector
An unrelated question. I'm using the Selector-script you suggest in your video to show when you can speak to an NPC. You can see its text popping up and working in this video here:
(See 00:00-00:30)
However sometimes it "flickers", as in it doesn't display despite being inside the NPC's 2Dcollider, and sometimes it does. (See the flicker in 00:30-01:00 in the video despite the NPC-collider seemingly being in the middle of screen).
I've chosen "Center Of the Screen" in the Selector (as my playable character is most often in the center of the screen), and turned on Run Raycasts "In 2D".
(You can see my selector-settings in 00:47-00:53 in the video).
Do you know what is causing this flickering? My guess is that I don't fully understand how the "Center of Screen" works, and perhaps I'll be better helped with another setting, like Custom Position or similar? Perhaps if I put Custom Position to my player's position it would work without the flickering?

Thank you so much for your excellent help and super-fast, high quality customer support replies. I'm so impressed by this asset.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: How turn off auto-advance on subtitle-dialogs?

Post by Tony Li »

Hi,
Hulda_Gnodima wrote: Sat Jan 18, 2020 6:01 am1. Unclickable Button
First check for any errors or warnings in the Console window. They may indicate a simple problem that you can address.

If not, settle in for a long wall of text since there are several possibilities. ;)

The Dialogue System uses plain old Unity UI and its EventSystem. Your scene probably has an EventSystem in it; otherwise the Dialogue System will automatically create a default one at runtime since it's required for Unity UI interaction.

The EventSystem has an input module (usually called Standalone Input Module) that responds to pointer (mouse) activity and 4 inputs defined in Edit > Project Settings > Input. By default, those 4 inputs are Horizontal & Vertical (navigates buttons with keyboard or joystick), Submit ("clicks" buttons), and Cancel. Submit is usually mapped to the enter key and space bar. The EventSystem keeps track of which button is currently selected. It's also possible for no button to be currently selected. When you press the Submit input (e.g., space bar), the EventSystem will click the selected button. If a subtitle panel's continue button is selected, pressing the space bar will click it. Note: If you have added a UI Button Key Trigger to the continue button and set it to Space, then this will end up clicking the continue button twice, which you don't want.

Also, if you have mapped "mouse button 0" to whatever input is set on the UI Button Key Trigger, then no matter where you click the UI Button Key Trigger will click the button. This may be what's happening with the button that's only clickable when the UI Button Key Trigger is enabled.

The Dialogue Manager's Canvas has a component called Graphic Raycaster that handles mouse input. Unless you've unticked the continue button's Raycast Target checkbox, the EventSystem will detect when the mouse is over the continue button. When you press the left mouse button, it will click the continue button. However, if another UI element (even a transparent one) is on top of the continue button, then it will block the Graphic Raycaster. To check this, you can keep the Inspector view on the EventSystem while playing in the editor. The details at the bottom of the Inspector view will report what UI element the pointer is over.

In addition, the Dialogue Manager's Input Device Manager component has several options that can change the EventSystem's behavior:
  • Input Device: If set to Joystick or Touch, it hides the mouse cursor. If you move the mouse, it automatically switches the dropdown to Mouse.
  • Always Auto Focus: If ticked, ensures that the EventSystem always keeps an appropriate button selected. If the conversation is showing a subtitle, it keeps the continue button selected so you can press the Submit input (e.g., space bar) to click it.
  • Detect Mouse Control: If unticked, it will not automatically switch the Input Device dropdown to Mouse.
  • Control Graphic Raycasters: Generally keep this unticked. If ticked, then when the Input Device is set to Joystick or Touch it will disable all Canvas's Graphic Raycaster components, preventing mouse input.
To summarize, check this:
  • Keep an Inspector view on the EventSystem. Are any UI elements blocking the continue button?
  • Is the Graphic Raycaster working, and is Raycast Target ticked on the continue button?
BTW, to click anywhere on the screen, the usual approach is to resize the continue button so it covers the entire screen, and make it use an invisible image. This way, no matter where the player clicks it will hit the continue button unless another UI element is on top of it.
Hulda_Gnodima wrote: Sat Jan 18, 2020 6:01 am2. Fast forwarding not working on NPC
Check how the Standard UI Continue Button Fast Forward components are set up on the PC and NPC panels. Make sure the continue button's OnClick() event is configured to call StandardUIContinueButtonFastForward.OnFastForward, and that the Typewriter Effect field is assigned.
Hulda_Gnodima wrote: Sat Jan 18, 2020 6:01 am3. Any key-press to advance convo?
It's not built in, but you could add a script like this to the continue button:

Code: Select all

using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class ClickOnAnyKey : MonoBehaviour
{
    void Update()
    {
        if (Input.anyKeyDown) // A key was pressed.
        {
            // Make sure the key wouldn't also click the button if the key is Submit and the button is currently selected:
            var isCurrentlySelected = EventSystem.current.currentSelectedGameObject == this.gameObject;
            if (!(isCurrentlySelected && Input.GetButtonDown("Submit"))
            {
                // Simulate a button click:
                GetComponent<Button>().onClick.Invoke();
            }
        }
    }
}
(I just typed the script into this reply; pardon any typos.)
Hulda_Gnodima wrote: Sat Jan 18, 2020 6:01 am4. Flickering Selector
Use a Proximity Selector instead.

When the Selector is set to Center of Screen, it runs a raycast through a single point in the exact center of the screen. It looks like sometimes the raycast happens to be just outside the NPC's collider.

Instead, try these steps on the player:
  • Remove the Selector.
  • Add a collider if the player doesn't already have one. (You can do these steps on a child GameObject if you prefer.)
  • Add a Rigidbody2D is the player doesn't already have one. Change Body Type to Kinematic.
  • Add a Proximity Selector. If you've put these components on a child GameObject, assign the main player GameObject to the Actor Transform field. Set the Use Key and/or Use Button to the input you want to use.
Now when the player's collider intersects with the NPC's trigger collider, the Proximity Selector will detect it, show the use message, and allow interaction when you press the Use Key or Use Button.

If you get stuck on any of this, please feel free to send a reproduction project to tony (at) pixelcrushers.com along with steps to reproduce the issues. If you pack up a reproduction project, you only need to zip up the Assets, ProjectSettings, and Packages folders. You can omit the other files and folders.
User avatar
Hulda_Gnodima
Posts: 19
Joined: Fri Jan 17, 2020 9:04 am

Re: How turn off auto-advance on subtitle-dialogs?

Post by Hulda_Gnodima »

First of all, WOW, thank you for sharing your expertise in such detail.

1. Unclickable Button
Thank you so much for that UI-explanation! I learned so many things I didn't know. And you were right, the button was simply not correctly placed in the hierarchy making it unclickable, so it was all me. I had no idea Eventsystem reported exactly which button it is hovering over, what a great tool for debugging.

2. Not Fast Forwarding NPC text
You were right about this too! The Continue-button only has one option for a TypeWriter Effect Script, and I had put in the PCs. However I'm using two different Subtitle texts (one for PC and one for NPC) so it was only working for the one the continue-button had assigned. Fixed it by duplicating the button and assigning the NPC-text, now it works wonderfully.

3. Any key to advance the conversation
That script works flawlessly! Thank you so very much, I'm very happy to use this.

4. Using A Proximity Selector instead.
I followed the steps you listed and it just worked! The flickering is gone, and I can so easily adjust the conversation-start range.

So in summary all my problems are now fixed and all my questions more than answered!

I'm a bit at a loss for words, there were so many things I thought were tricky and they're all now fixed thanks to your help. You've really gone above and beyond. I can only express my heartfelt gratitude. Your efforts have saved my so much time, and your asset is wonderful. I can't wait to dig in and continue customizing it. Thank you a million times! :D
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: How turn off auto-advance on subtitle-dialogs?

Post by Tony Li »

Glad to help! :-) Have fun making your game.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: How turn off auto-advance on subtitle-dialogs?

Post by Tony Li »

And thank you very much for the kind review! :-)
Post Reply