using keycode input

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
robin
Posts: 2
Joined: Sun Jul 22, 2018 10:49 am

using keycode input

Post by robin »

FF6_Password.png
FF6_Password.png (128.71 KiB) Viewed 1108 times
Hello, I just started experimenting with this yesterday and I am loving the Dialogue System so far!

I would like the player to select from the dialogue choices using keycode input (E key). I added the UI Button Key Trigger component to the Response Button Template and can now select the first option with the E key. I can use the up and down arrows to highlight the other options, but the selection immediately reverts back to the first option before a player can hit the E key. Is there a way to cycle through the options using up arrow/W key and down arrow/S key without the selection automatically reverting to the first choice?

Is there a simple way to indicate the selection with a symbol like the example above in FF6?

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

Re: using keycode input

Post by Tony Li »

Hi,

Thanks for using the Dialogue System! (I think you were also at TheMessyCoder's Twitch interview yesterday; if so, thanks for tuning into that, too!)

Here's an example scene: FF6StyleExample_2018-07-22.unitypackage

In the example scene, to show a symbol next to the current selection, I changed the response button's Transition to Sprite Swap. Then I assigned a blank sprite for the normal button state and an arrow sprite for the highlighted state.

Just for fun, I also added a Unity UI Event Trigger component and configured it to play an audio clip.

The example dialogue UI uses the Dialogue System's Standard Dialogue UI (tutorial), which uses Unity UI navigation.

The Dialogue Manager GameObject has a component named Input Device Manager. This component detects switches between keyboard, joystick, and mouse control modes. If you move the mouse, it switches to mouse mode. In mouse mode, it won't auto-highlight a response button since it's expected that you'll highlight one by hovering your mouse cursor over it. If you want to prevent mouse mode, untick the Input Device Manager's Detect Mouse Control checkbox. If you're in keyboard or joystick mode, the response menu panel will make sure a response button is always highlighted so you can navigate them. In the example, I ticked the menu panel's Navigation > Loop Explicit Navigation checkbox. This sets up navigation so if you press S/down on the bottom button it will loop back to the top one.

By default, Unity UI's EventSystem watches for the Unity Input button named "Submit", which is mapped to Enter and Space. You can edit Submit (Edit > Project Settings > Input) and map it to 'E' instead.

Then you can remove the UI Button Key Trigger component, which I think may be causing the issue. The response menu makes a copy of the response button template for every response. If the template has a UI Button Key Trigger set to E, then all of the actual response buttons in the menu will also be mapped to E. This means that when you press E all of the UI Button Key Triggers on all of the buttons will try to click their buttons at the same time. Instead, you'll want to map E to the Submit input so the EventSystem just clicks the currently-selected button.
robin
Posts: 2
Joined: Sun Jul 22, 2018 10:49 am

Re: using keycode input

Post by robin »

Thank you so much for your help, Tony! :D (Btw - that must have been someone else at the twitch interview.)
User avatar
Tony Li
Posts: 22058
Joined: Thu Jul 18, 2013 1:27 pm

Re: using keycode input

Post by Tony Li »

Happy to help!
Post Reply