Page 1 of 1
UI Button Key Trigger -> Standard Dialogue Continue Button Fast Forward problem.
Posted: Thu Feb 07, 2019 2:06 pm
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!
Re: UI Button Key Trigger -> Standard Dialogue Continue Button Fast Forward problem.
Posted: Thu Feb 07, 2019 2:59 pm
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).
Re: UI Button Key Trigger -> Standard Dialogue Continue Button Fast Forward problem.
Posted: Thu Feb 07, 2019 3:07 pm
by Japtor
Hi,
Thank you. It worked!
Re: UI Button Key Trigger -> Standard Dialogue Continue Button Fast Forward problem.
Posted: Thu Feb 07, 2019 3:16 pm
by Tony Li
Great! Happy to help.