Hi,
Yes, you could use a conversation to select another conversation.
As a first step, I recommend doing it all with the same dialogue UI, such as the Basic Standard Dialogue UI.
Let's say the first conversation is titled "Contacts" and each NPC contact has a conversation titled "NPC A", "NPC B", "NPC C", etc.
In the Contacts conversation, show a menu of conversation titles (one title per response node: NPC A, NPC B, etc.). In each response node, set a variable "ChosenContact" to the NPC's conversation title. Example:
- Dialogue Text: "Chat with NPC A"
- Script: Variable["ChosenContact"] = "NPC A"
Add a script to the Dialogue Manager that has
OnConversationStart and OnConversationEnd methods. In OnConversationStart, set the ChosenContact variable to a blank string. In OnConversationEnd, check if the variable has been set to a conversation title; if so, start that conversation. Example:
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class ContactSelectionHandler : MonoBehaviour
{
// When a conversation starts, reset the ChosenContact variable:
void OnConversationStart(Transform actor)
{
DialogueLua.SetVariable("ChosenContact", string.Empty);
}
// When a conversation ends, check if ChosenContact was set. If so, start the NPC conversation:
void OnConversationEnd(Transform actor)
{
string chosenContact = DialogueLua.GetVariable("ChosenContact").asString;
if (!string.IsNullOrEmpty(chosenContact))
{
DialogueManager.StartConversation(chosenContact);
}
}
}
---
The second part is to use different dialogue UIs. One way to do this is to assign a different dialogue UI to the Dialogue Manager. You can build on the script above:
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class ContactSelectionHandler : MonoBehaviour
{
// Assign these in the inspector:
public StandardDialogueUI computerUI;
public StandardDialogueUI smsUI;
// When a conversation starts, reset the ChosenContact variable:
void OnConversationStart(Transform actor)
{
DialogueLua.SetVariable("ChosenContact", string.Empty);
}
// When a conversation ends, check if ChosenContact was set. If so, start the NPC conversation:
void OnConversationEnd(Transform actor)
{
string chosenContact = DialogueLua.GetVariable("ChosenContact").asString;
if (!string.IsNullOrEmpty(chosenContact))
{
// When starting an NPC conversation, use the smsUI:
DialogueManager.UseDialogueUI(smsUI.gameObject);
DialogueManager.StartConversation(chosenContact);
}
else
{
// Otherwise reset back to the computer UI as the default UI:
DialogueManager.UseDialogueUI(computerUI.gameObject);
}
}
}