Hello,
how do I bind a keystroke to a response buttons? I mean I would like to have bound numbers from 1-9 to each of my responses, and in case there is only one response available, also Space to trigger the lone response. Is ther an event for that?
Best!
Dialogue response button binding setup
Re: Dialogue response button binding setup
Hi,
Add a UI Button Key Trigger component to the button.
If you tick Auto Focus, it will highlight the first response. If you press the spacebar, it will trigger the highlighted response.
If you're using a response button template that instantiates buttons at runtime, you'll have to assign the right key at runtime. The next release of the Dialogue System will have an option to do this automatically for you. In the meantime, if you need to set this up, let me know and I can provide more details.
Add a UI Button Key Trigger component to the button.
If you tick Auto Focus, it will highlight the first response. If you press the spacebar, it will trigger the highlighted response.
If you're using a response button template that instantiates buttons at runtime, you'll have to assign the right key at runtime. The next release of the Dialogue System will have an option to do this automatically for you. In the meantime, if you need to set this up, let me know and I can provide more details.
Re: Dialogue response button binding setup
Hi Tony,
splendid! I'm using a button's template, though I will write a script for runtime assignment by myself. Should I have any problems, I will let you know.
Best!
splendid! I'm using a button's template, though I will write a script for runtime assignment by myself. Should I have any problems, I will let you know.
Best!
Re: Dialogue response button binding setup
Hi Tony,
from what I see my best option is to add UI Button Key Trigger component to each of the clones of response buttons residing under Scroll Content, probably when ShowResponses is called. The references to the clones are under buttonTemplateHolder at UnityUIResponseMenuControls, am I right?
Best!
from what I see my best option is to add UI Button Key Trigger component to each of the clones of response buttons residing under Scroll Content, probably when ShowResponses is called. The references to the clones are under buttonTemplateHolder at UnityUIResponseMenuControls, am I right?
Best!
Re: Dialogue response button binding setup
Hi,
EDIT: I forgot there's already a script and example on the Extras page. It's the second download button in the UIs section.
That's just about right. If you add a UIButtonKeyTrigger to the template button, all instantiated versions will have it, too. The instantiated buttons are in the instantiatedButtons property. You can set them like this:
EDIT: I forgot there's already a script and example on the Extras page. It's the second download button in the UIs section.
That's just about right. If you add a UIButtonKeyTrigger to the template button, all instantiated versions will have it, too. The instantiated buttons are in the instantiatedButtons property. You can set them like this:
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class MyDialogueUI : UnityUIDialogueUI {
public override void ShowResponses(Subtitle subtitle, Response[] responses, float timeout) {
// Set up the buttons as normal:
base.ShowResponses(subtitle, responses, timeout);
// Then set the number keys:
foreach (int i = 0; i < dialogue.responseMenu.instantiatedButtons.Count; i++) {
var key = (KeyCode) ((int)KeyCode.Alpha0 + i);
var button = dialogue.responseMenu.instantiatedButtons[i];
button.GetComponent<UIButtonKeyTrigger>().key = key;
}
}
}
Re: Dialogue response button binding setup
Tony,
thank you very much!
Best
thank you very much!
Best