UI Button Key Trigger -> Standard Dialogue Continue Button Fast Forward problem.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Japtor
Posts: 120
Joined: Thu Jun 28, 2018 1:41 pm

UI Button Key Trigger -> Standard Dialogue Continue Button Fast Forward problem.

Post by Japtor »

Hi,

Inside the continue Button from the Standart Dialogue UI, I have a Standard Dialogue Continue Button Fast Forward and a UI Button Key Trigger (Key = Space).

If I click the button manually when the text is using the Text Mesh Pro Typewriter Effect, it automatically completes it instead going to the next conversation node. This is perfect, as its the way I want to have it. However, If I use the Space key while the text is using the Text Mesh Pro Typewriter Effect, it automatically goes to the next Dialogue node from the conversation.

Any idea why is this happening?

Thanks! :)
User avatar
Tony Li
Posts: 22129
Joined: Thu Jul 18, 2013 1:27 pm

Re: UI Button Key Trigger -> Standard Dialogue Continue Button Fast Forward problem.

Post by Tony Li »

The space key is also the EventSystem's Submit input. If the EventSystem's current selection is on the continue button, the EventSystem will click the button when you press space. But the UIButtonKeyTrigger will also click the button when you press space. This results in two clicks.

One solution is to remove the UIButtonKeyTrigger and tick the Dialogue Manager's Input Device Manager > Always Auto Focus. This will make sure that the EventSystem keeps the current selection on the continue button.

Another solution is to make a copy of UIButtonKeyTrigger that checks the EventSystem's current selection. If the current selection is UIButtonKeyTrigger's GameObject, then don't do a second click. For example, change the Update method from this:

Code: Select all

void Update()
{
    if (Input.GetKeyDown(key) || (!string.IsNullOrEmpty(buttonName) && InputDeviceManager.IsButtonDown(buttonName)))
    {
        ExecuteEvents.Execute(m_selectable.gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.submitHandler);
    }
}
to this:

Code: Select all

void Update()
{
    if (Input.GetKeyDown(key) || (!string.IsNullOrEmpty(buttonName) && InputDeviceManager.IsButtonDown(buttonName)))
    {
        if (EventSystem.current.currentSelectedGameObject != this.gameObject)
        {
            ExecuteEvents.Execute(m_selectable.gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.submitHandler);
        }
    }
}
This assumes that the UIButtonKeyTrigger's Key is set to one of the keys assigned to "Submit" in Unity's Input Manager (space or return).
Japtor
Posts: 120
Joined: Thu Jun 28, 2018 1:41 pm

Re: UI Button Key Trigger -> Standard Dialogue Continue Button Fast Forward problem.

Post by Japtor »

Hi,

Thank you. It worked! :)
User avatar
Tony Li
Posts: 22129
Joined: Thu Jul 18, 2013 1:27 pm

Re: UI Button Key Trigger -> Standard Dialogue Continue Button Fast Forward problem.

Post by Tony Li »

Great! Happy to help.
Post Reply