Dialogue UI that is keyboard (or gamepad) driven, rather than relying on cursor

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
chainsawPenguin
Posts: 5
Joined: Fri Dec 26, 2014 12:06 pm

Dialogue UI that is keyboard (or gamepad) driven, rather than relying on cursor

Post by chainsawPenguin »

Can  anyone point me to where it is explained how to do this? I get that the checkmark is incorporated into UnityUIDialogueUI, but I have no idea how to create a dialogue UI that uses that script.



Any suggestions?
User avatar
Tony Li
Posts: 21020
Joined: Thu Jul 18, 2013 1:27 pm

Dialogue UI that is keyboard (or gamepad) driven, rather than relying on cursor

Post by Tony Li »

If you're using the new Unity UI in Unity 4.6+, then to enable keyboard and gamepad navigation just tick Auto Focus at the bottom of the Unity UI Dialogue UI component. When it shows the response menu, it will focus on the first button. From that point, it just uses Unity UI's built-in navigation. For more info on that, skip to 07:50 of Unity's UI button tutorial.







If you're using the legacy Unity GUI, then to enable keyboard and gamepad navigation:



1. Inspect the Response Panel in your UI object.



If your UI is a prefab, drag it into the scene so you can edit it:





Assign the scene instance to the Dialogue Manager's Dialogue UI field:





2. In the Response Panel's Navigation section, tick Enabled. This will let you navigate with keys and gamepads.







3. If your response buttons aren't already assigned to Order, assign them in the order that they should be navigated.



4. By default, Unity GUI clicks the currently-focused control when Space is pressed. Set Click to change this behaviour. Set Button Click to set the name of a user-defined button (e.g., gamepad button) that will also click the currently-focused control.



5. The Previous & Next keys navigate back and forth.



6. The Axis settings specify which gamepad axis controls navigation, and how fast.



7. Adjust Mouse Wheel Sensitivity to tune the speed that the mouse wheel navigates through responses.



When you're done, you can save it as a new prefab and assign that prefab to the Dialogue Manager's Dialogue UI field. Or you can continue to use the scene instance. In this case, if your game switches scenes, you should make it a child of Dialogue Manager so it doesn't get destroyed during the scene change.


chainsawPenguin
Posts: 5
Joined: Fri Dec 26, 2014 12:06 pm

Dialogue UI that is keyboard (or gamepad) driven, rather than relying on cursor

Post by chainsawPenguin »

That... was perfect.  Thanks!



Now i regret spending so long trying to sort it out on my own. Good stuff!!
User avatar
Tony Li
Posts: 21020
Joined: Thu Jul 18, 2013 1:27 pm

Dialogue UI that is keyboard (or gamepad) driven, rather than relying on cursor

Post by Tony Li »

Happy to help! That's what I'm here for, so if any other questions come up, don't hesitate to ask!
Post Reply