Interacting with Response using keyboard/controller

Announcements, support questions, and discussion for the Dialogue System.
nishant
Posts: 55
Joined: Mon Sep 21, 2015 3:16 pm
Location: Canada
Contact:

Interacting with Response using keyboard/controller

Post by nishant »

Hi,
Is there any way to use keys to interact with Responses ?? I want something like ... 1st response will be highlighted and I can use arrow keys to change the option and then another key to confirm. Is this possible ??

Thanks.
Nishant
nishant
Posts: 55
Joined: Mon Sep 21, 2015 3:16 pm
Location: Canada
Contact:

Re: Interacting with Response using keyboard/controller

Post by nishant »

Just an update on things that I have checked .

1. This question is there in FAQs .Its mentioned ' In the Navigation section, tick Enabled. This will let you navigate with keys and gamepads. You can customize the behavior using the other options available in the Navigation section'. However I couldn't find this option in Response Panel ; the only Navigation option that is present is in the button object but it doesnt show any tick mark or other options that answer refers to.

2. I have a feeling that this can be solved with QTE but not sure how that works.
User avatar
Tony Li
Posts: 22102
Joined: Thu Jul 18, 2013 1:27 pm

Re: Interacting with Response using keyboard/controller

Post by Tony Li »

Hi Nishant,

It depends on the GUI system you're using.

If you're using Unity UI, set up Unity's standard keyboard/controller navigation as described on Unity's Navigation page. Then on your dialogue UI tick Auto Focus to automatically highlight the first response. More info is here.

If you're using legacy Unity GUI, follow these steps.

If you're using a different GUI system, please let me know which one. The procedure is different for every GUI system.
nishant
Posts: 55
Joined: Mon Sep 21, 2015 3:16 pm
Location: Canada
Contact:

Re: Interacting with Response using keyboard/controller

Post by nishant »

Hey Toni,
Yes I am using Unity UI . I tried to set auto-focus but didnt work . Is it because I am locking the mouse cursor in my game ?
alfonso
Posts: 104
Joined: Mon Jul 13, 2015 6:31 am

Re: Interacting with Response using keyboard/controller

Post by alfonso »

Hi, this code configure the buttons as Explicit and i can choose response with the stick of the controller or with W,S in the keyboard

Hope this will useful for you :)

nota: in the response settings of the dialogue system gameobject, i use a button template so dialogueSystem generete all the responses that the Conversation need and then this code configure their navitation and preselect the first one.

Code: Select all

		#region Response
		public override void ShowResponses (Subtitle subtitle, Response[] responses, float timeout)
		{
			base.ShowResponses(subtitle, responses, timeout);
			
			if(responses.Length > 0) 
				SetButtonsNav();
		}
		
		public override void HideResponses() 
		{
			dialogue.responseMenu.DestroyInstantiatedButtons();
			base.HideResponses();
		}
		
		void SetButtonsNav()
		{
			List<GameObject> buttons = dialogue.responseMenu.instantiatedButtons;
			int totals = buttons.Count;
			for(int i = 0; i < totals; i++)
			{
				Navigation n = new Navigation();
				n.mode = Navigation.Mode.Explicit;
				n.selectOnUp = (i == 0)? buttons[totals-1].GetComponent<Button>(): buttons[i-1].GetComponent<Button>();
				n.selectOnDown = (i == totals-1)? buttons[0].GetComponent<Button>(): buttons[i+1].GetComponent<Button>();
				buttons[i].GetComponent<Button>().navigation = n;
			}
			StartCoroutine(SetSelectedGameObject(buttons[0]));
		}

		IEnumerator SetSelectedGameObject(GameObject o)
		{
			//we need to wait to the next cicle :( otherwise we go into the same 
			//update how call the response and get the effect of autoselect.
			yield return null;
			UnityEngine.EventSystems.EventSystem.current.SetSelectedGameObject(o);
		}
		#endregion
nishant
Posts: 55
Joined: Mon Sep 21, 2015 3:16 pm
Location: Canada
Contact:

Re: Interacting with Response using keyboard/controller

Post by nishant »

Hey ,
Thanks for that :) I almost came up with something similar but this is way cleaner . 1 doubt , how am I supposed to bind the keys ?? be it w/s or controller ?
alfonso
Posts: 104
Joined: Mon Jul 13, 2015 6:31 am

Re: Interacting with Response using keyboard/controller

Post by alfonso »

in the unity input settings you can configure this kind of stuff normaly is autoconfigure to use WS to up down in the keyboard for the devices i use incontrol how implement the same settings of unity but overriding to the controller.

hope this help you
nishant
Posts: 55
Joined: Mon Sep 21, 2015 3:16 pm
Location: Canada
Contact:

Re: Interacting with Response using keyboard/controller

Post by nishant »

I am aware of Input Manager . I wanted to know how can I tell the compiler to SelectOnUp when i press W or is that done automatically ? Maybe it does that when focus is on any button ?? I cant get auto-focus to work either ; probably thats why I cant navigate around.
User avatar
Tony Li
Posts: 22102
Joined: Thu Jul 18, 2013 1:27 pm

Re: Interacting with Response using keyboard/controller

Post by Tony Li »

Please feel free to send an example project to tony (at) pixelcrushers.com. I'll be happy to take a look, too.
nishant
Posts: 55
Joined: Mon Sep 21, 2015 3:16 pm
Location: Canada
Contact:

Re: Interacting with Response using keyboard/controller

Post by nishant »

Thanks :) will do so as a last resort .
Post Reply