Hi there again,
So this time I need a way to detect if the line we just received has a reponse menu or not.
This is how I need my code to work:
public void OnConversationLine(Subtitle subtitle)
{
If (subtitle has response options?)
{
Do nothing.
}
if (subtitle doesn't have response options)
{
Pause this conversation until I unpause you in a different bit of code.
}
}
Thanks for any help.
Registering when a node has a reponse or not
-
- Posts: 91
- Joined: Tue Jul 14, 2015 8:22 am
Re: Registering when a node has a reponse or not
Hi,
While you could use an OnConversationLine method, it would work better to make a subclass of your dialogue UI. Let's assume you're using UnityUIDialogueUI. Try this script (MyDialogueUI.cs):
Drag this onto your dialogue UI's Script field to replace UnityUIDialogueUI with MyDialogueUI.
When the Dialogue System tells the UI to show responses, this script will just save the response info; it won't actually show the menu.
When your different bit of code is ready to show the response menu, call ShowResponseForRealNow().
BTW, not that you'll need it if you use the code above, but you can use DialogueManager.CurrentConversationState to determine whether the current conversation state is followed by a player response menu. You'll want to check if the PC has any responses and if the NPC doesn't. NPC responses always take precedence; if there's an NPC response, it will play instead of a player response menu.
While you could use an OnConversationLine method, it would work better to make a subclass of your dialogue UI. Let's assume you're using UnityUIDialogueUI. Try this script (MyDialogueUI.cs):
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class MyDialogueUI : UnityUIDialogueUI {
private Subtitle savedSubtitle;
private Response[] savedResponses;
private float savedTimeout;
public override void ShowResponses(Subtitle subtitle, Response[] responses, float timeout) {
// Just save the response menu info; don't
savedSubtitle = subtitle;
savedResponses = responses;
savedTimeout = timeout;
}
public void ShowResponsesForRealNow() {
base.ShowResponses(savedSubtitle, savedResponses, savedTimeout);
}
}
When the Dialogue System tells the UI to show responses, this script will just save the response info; it won't actually show the menu.
When your different bit of code is ready to show the response menu, call ShowResponseForRealNow().
BTW, not that you'll need it if you use the code above, but you can use DialogueManager.CurrentConversationState to determine whether the current conversation state is followed by a player response menu. You'll want to check if the PC has any responses and if the NPC doesn't. NPC responses always take precedence; if there's an NPC response, it will play instead of a player response menu.
Code: Select all
var responseMenuIsNext = DialogueManager.CurrentConversationState.HasPCResponses &&
!DialogueManager.CurrentConversationState.HasNPCResponse;