[HOWTO] How To: Continue Without UI Button

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

[HOWTO] How To: Continue Without UI Button

Post by Tony Li »

If you've set up your conversations to wait for a continue button click, normally the player will continue by clicking a UI button.

However, there are several ways to continue without the UI button:

1. Use the Continue() sequencer command in a sequence, such as the Sequence below to continue after 2 seconds:

Code: Select all

Continue()@2
2. Use the UI button, but size it to cover the whole screen, and set its Image color alpha to zero so it's invisible. This allows the player to click/tap anywhere onscreen to continue. You can usually move it to be a direct child of the Dialogue Panel and/or add a Layout Element and tick Ignore Layout. This will make it easier to configure the Rect Transform to cover the whole screen.

3. Add a UIButtonKeyTrigger to the UI button. This lets you map additional inputs to click the button. Don't use Space or Return for UIButtonKeyTrigger hotkeys; Space and Return are already used by the Unity UI EventSystem to click the current selection. If you add them to UIButtonKeyTrigger, they can end up incorrectly clicking the button twice.

4. Or remove the continue button(s) from your dialogue UI, and add this script to your Subtitle Text GameObjects:

ContinueFastForward.cs

Code: Select all

using PixelCrushers.DialogueSystem;
using UnityEngine;

public class ContinueFastForward : MonoBehaviour
{
    public KeyCode[] continueKeys = new KeyCode[] { KeyCode.Space, KeyCode.Return };

    void Update()
    {
        foreach (var key in continueKeys)
        {
            if (InputDeviceManager.IsKeyDown(key))
            {
                FastForward();
                return;
            }
        }
    }

    void FastForward()
    {
        var typewriterEffect = GetComponent<AbstractTypewriterEffect>();
        if ((typewriterEffect != null) && typewriterEffect.isPlaying)
        {
            typewriterEffect.Stop();
        }
        else
        {
            GetComponentInParent<AbstractDialogueUI>().OnContinue();
        }
    }
}
JohnnyCenter
Posts: 1
Joined: Thu Dec 05, 2019 3:28 pm

Re: How To: Continue Without UI Button

Post by JohnnyCenter »

Worked like a charm. Thank you for your efforts :)
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: How To: Continue Without UI Button

Post by Tony Li »

Glad to help! :-)
DrewThomasArt
Posts: 60
Joined: Thu Mar 24, 2022 12:07 am

Re: [HOWTO] How To: Continue Without UI Button

Post by DrewThomasArt »

Hello, where exactly do I put the "ContinueFastForward" script? I've tried putting it on every Game Object in the Dialogue Manager and it still doesn't continue when I hit the button. (Whether it be space, enter, or the key I set it to.)
Last edited by DrewThomasArt on Thu Mar 24, 2022 8:14 pm, edited 2 times in total.
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: [HOWTO] How To: Continue Without UI Button

Post by Tony Li »

Hi,

Put it on the subtitle panel's Subtitle Text GameObject.
DrewThomasArt
Posts: 60
Joined: Thu Mar 24, 2022 12:07 am

Re: [HOWTO] How To: Continue Without UI Button

Post by DrewThomasArt »

Tony Li wrote: Thu Mar 24, 2022 7:57 pm Hi,

Put it on the subtitle panel's Subtitle Text GameObject.
I see why I'm confused, the "JRPG" Template doesn't have the subtitle panel, but I just checked the "Focus" template and it does
Is there any way to do this for the JRPG template?

Alternatively, I got it to work with spacebar, but clicking breaks it. It works fine but if the user clicks than key presses don't work at all. If there was a way to disable fast forwarding with clicks, that would also work

Thank you
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: [HOWTO] How To: Continue Without UI Button

Post by Tony Li »

Hi,

The JRPG template has a subtitle panel. It's just tucked away kind of deep:

jrpgSubtitlePanel.png
jrpgSubtitlePanel.png (19.89 KiB) Viewed 2109 times

If you want to get rid of the fast forward feature instead, remove the continue button's Standard UI Continue Button Fast Forward component, and configure the Button's OnClick to call the Subtitle Panel's OnContinue() method:

jrpgNoFastForward.png
jrpgNoFastForward.png (57.91 KiB) Viewed 2109 times
DrewThomasArt
Posts: 60
Joined: Thu Mar 24, 2022 12:07 am

Re: [HOWTO] How To: Continue Without UI Button

Post by DrewThomasArt »

Tony Li wrote: Thu Mar 24, 2022 8:33 pm Hi,

The JRPG template has a subtitle panel. It's just tucked away kind of deep:


jrpgSubtitlePanel.png


If you want to get rid of the fast forward feature instead, remove the continue button's Standard UI Continue Button Fast Forward component, and configure the Button's OnClick to call the Subtitle Panel's OnContinue() method:


jrpgNoFastForward.png
I appreciate you taking the time to upload screenshots,

And thank you, that works now that I can find the right GameObject (sheesh, my bad)

Now, the key that I set only works for the NPC dialogue that has the continue button. Is there a way to also use the keypress that I set in your "ContinueFastForward" script to also skip the player's response dialogue?
DrewThomasArt
Posts: 60
Joined: Thu Mar 24, 2022 12:07 am

Re: [HOWTO] How To: Continue Without UI Button

Post by DrewThomasArt »

DrewThomasArt wrote: Thu Mar 24, 2022 10:23 pm
Tony Li wrote: Thu Mar 24, 2022 8:33 pm Hi,

The JRPG template has a subtitle panel. It's just tucked away kind of deep:


jrpgSubtitlePanel.png


If you want to get rid of the fast forward feature instead, remove the continue button's Standard UI Continue Button Fast Forward component, and configure the Button's OnClick to call the Subtitle Panel's OnContinue() method:


jrpgNoFastForward.png
I appreciate you taking the time to upload screenshots,

And thank you, that works now that I can find the right GameObject (my bad, that's embarrassing)

Now, the key that I set only works for the NPC dialogue that has the continue button. Is there a way to also use the keypress that I set in your "ContinueFastForward" script to also skip the player's response dialogue?

Edit: Figured it out. I just unchecked "is Player" in the Actor window from the editor. I'm all set now, thanks
timbecile
Posts: 110
Joined: Mon Mar 12, 2018 11:00 pm

Re: [HOWTO] How To: Continue Without UI Button

Post by timbecile »

Hey Tony,

I am trying to implement this. The script works good, but the Response panel takes forever to become active. (it's still waiting the same amount of time for the text to finish. Is there a way to speed that up through the script and make it active at the same time?
Post Reply