Skip dialogue choices outside of dialogue
Skip dialogue choices outside of dialogue
How might one accomplish the following:
In the dialogue you are given various options, but outside of the dialogue you can take an action that will move the dialogue to a result that is only selected if you take action outside of the dialogue.
Another way of asking this is imagine a made up situation where there are 2 dialogue choices:
Yes
No
And then there's a button outside the dialogue that says "Maybe".
Each of these three buttons have their own dialogue result.
How might this 'Maybe' button notify the dialogue system to go to that third result?
In the dialogue you are given various options, but outside of the dialogue you can take an action that will move the dialogue to a result that is only selected if you take action outside of the dialogue.
Another way of asking this is imagine a made up situation where there are 2 dialogue choices:
Yes
No
And then there's a button outside the dialogue that says "Maybe".
Each of these three buttons have their own dialogue result.
How might this 'Maybe' button notify the dialogue system to go to that third result?
Re: Skip dialogue choices outside of dialogue
Hi,
I'll assume that you want to define the Maybe button in the conversation editor, so the question node actually links to 3 response nodes (Yes, No, Maybe).
On the Dialogue Editor window's Templates page, you could add a custom field to the dialogue entry template to indicate that the entry's button should appear outside the regular menu.
Then use a subclass of StandardUIMenuPanel that overrides the SetResponseButtons method. For each response, if the custom field indicates the button should appear outside the regular menu, add it there. Rough example:
I'll assume that you want to define the Maybe button in the conversation editor, so the question node actually links to 3 response nodes (Yes, No, Maybe).
On the Dialogue Editor window's Templates page, you could add a custom field to the dialogue entry template to indicate that the entry's button should appear outside the regular menu.
Then use a subclass of StandardUIMenuPanel that overrides the SetResponseButtons method. For each response, if the custom field indicates the button should appear outside the regular menu, add it there. Rough example:
Code: Select all
public class MyMenuPanel : StandardUIMenuPanel
{
protected override void SetResponseButtons(Response[] responses, Transform target)
{
var regularResponses = new List<Response>();
foreach (var response in responses)
{
if (Field.LookupBool(response.destinationEntry.fields, "Show Outside UI"))
{
// Show special response button somewhere else
}
else
{
regularResponses.Add(response);
}
}
base.SetResponseButtons(regularResponses.ToArray(), target);
}
}
Re: Skip dialogue choices outside of dialogue
Oooh I like this.
So let me expand into a specific use-case.
You are given a selection of cards - you can respond "No I don't want any of these" in the dialogue, or you can select a card - each one has a different reaction. (Examples attached)
In the example, would there be a way for it to attach itself to those card selection buttons, so that when you click on any one of them, it triggers the <Card Selected> node and drops into the "Our Contract is complete." node?
Thanks
So let me expand into a specific use-case.
You are given a selection of cards - you can respond "No I don't want any of these" in the dialogue, or you can select a card - each one has a different reaction. (Examples attached)
In the example
Code: Select all
// Show special response button somewhere else
Thanks
- Attachments
-
- 2021-05-26 17_14_43-Twilight Tower - Playing - PC, Mac & Linux Standalone - Unity 2020.3.8f1 Persona.png (59.63 KiB) Viewed 1480 times
-
- 2021-05-26 17_17_22-Game.png (891.39 KiB) Viewed 1480 times
Re: Skip dialogue choices outside of dialogue
It's easiest if you set up the <Card Selected> node to always be in a specific position in the response list, such as the first response. Then you can configure your card buttons to click the first response. Example:
Code: Select all
private Response cardSelectedResponse;
public void OnConversationResponseMenu(Response[] responses)
{
cardSelectedResponse = responses[0];
}
public void SelectCard(int cardNumber)
{
// Record the selected card number for the Dialogue System:
DialogueLua.SetVariable("SelectedCardNumber", cardNumber);
// Tell the StandardDialogueUI to use the card selected response:
(DialogueManager.dialogueUI as StandardDialogueUI).OnClick(cardSelectedResponse);
}
Re: Skip dialogue choices outside of dialogue
Great! I'll give this a try, thank you!
Re: Skip dialogue choices outside of dialogue
Happy to help!
Re: Skip dialogue choices outside of dialogue
Worked like a charm. Here's what I ended up using:
Thanks again
Code: Select all
protected override void SetResponseButtons(Response[] responses, Transform target)
{
var regularResponses = new List<Response>();
foreach (var response in responses)
{
if (Field.LookupBool(response.destinationEntry.fields, "CardButton"))
{
// Show special response button somewhere else
cardSelectedResponse = response;
}
else
{
regularResponses.Add(response);
}
}
base.SetResponseButtons(regularResponses.ToArray(), target);
}
public void SelectCard()
{
if (Field.LookupBool(cardSelectedResponse.destinationEntry.fields, "CardButton"))
{
(DialogueManager.dialogueUI as StandardDialogueUI).OnClick(cardSelectedResponse);
ResponseMenuController.I.cardSelectedResponse = null;
}
}
Re: Skip dialogue choices outside of dialogue
Awesome! Glad to help.
Re: Skip dialogue choices outside of dialogue
Is there a way I could show potential responses in the dialogue, but you can't select one there - instead, you do things in the game and it makes a selection for you?
Sort of like making dialogue selections via your behavior.
Sort of like making dialogue selections via your behavior.
Re: Skip dialogue choices outside of dialogue
Yes. Here are two ways to do that:
1. Make a subclass of StandardUIMenuPanel that overrides the behavior. For example, it could set all of the buttons non-interactable, and instead let actions in the game call the buttons' StandardUIResponseButton.OnClick() methods.
2. Or assign anything to the response buttons' Button component > OnClick() UnityEvent. If anything is assigned to OnClick(), the StandardUIResponseButton component will not automatically add its own OnClick() method to the UnityEvent. This means clicking the button will not select the response. When the player performs a game action, loop through the responses to identify the button that corresponds to the game action. Then call its StandardUIResponseButton.OnClick() method.
1. Make a subclass of StandardUIMenuPanel that overrides the behavior. For example, it could set all of the buttons non-interactable, and instead let actions in the game call the buttons' StandardUIResponseButton.OnClick() methods.
2. Or assign anything to the response buttons' Button component > OnClick() UnityEvent. If anything is assigned to OnClick(), the StandardUIResponseButton component will not automatically add its own OnClick() method to the UnityEvent. This means clicking the button will not select the response. When the player performs a game action, loop through the responses to identify the button that corresponds to the game action. Then call its StandardUIResponseButton.OnClick() method.