The Dialogue System and several other tools are in a Humble Bundle sale: Unity Tools Bundle
You can get the entire bundle for $30 USD. That's 98% off the regular price. The sale ends in 4 days.
Change the alpha value of the text's Color to 255:
The Dialogue System and several other tools are in a Humble Bundle sale: Unity Tools Bundle
Change the alpha value of the text's Color to 255:
Code: Select all
public void CreateResponseTree(List<Narrator> narrators)
{
int i = 0;
foreach (Narrator narrator in narrators)
{
CreateReply(++i);
}
}
private void CreateReply(int i)
{
var conversationID = DialogueManager.currentConversationState.subtitle.dialogueEntry.conversationID;
int nodeID = DialogueManager.currentConversationState.subtitle.dialogueEntry.id;
var template = Template.FromDefault();
Conversation conversation = DialogueManager.masterDatabase.GetConversation(conversationID);
var startNode = DialogueManager.currentConversationState.subtitle.dialogueEntry;
var responseNode = template.CreateDialogueEntry(template.GetNextDialogueEntryID(conversation), conversation.id, string.Empty);
responseNode.DialogueText = $"Approach a tavern visitor #{i}";
var link = new Link(conversation.id, nodeID, conversation.id, responseNode.id);
startNode.outgoingLinks.Add(link);
}
Code: Select all
void OnConversationResponseMenu(Response[] responses)
{
for (int i = 0; i < responses.Length; i++)
{
responses[i].formattedText.text = $"Answer {i} text.";
}
}
sorry for the inaccuracy, I meant to put a custom script in a node that is created through a C # script.
Code: Select all
responseNode.userScript = "[Variable[\"NarratorType\"] = \"0\"]";
So, I cannot add another one to that three responses at runtime, right?
Code: Select all
responseNode.userScript = "[Variable[\"NarratorType\"] = \"0\"]";
Code: Select all
public class MyDialogueUI : StandardDialogueUI
{
public override void ShowResponses(Subtitle subtitle, Response[] responses, float timeout)
{
// Add an extra response:
var formattedText = FormattedText.Parse("This is a new response.");
var destinationEntry = DialogueManager.masterDatabase.GetDialogueEntry(7, 42); // Get conv ID 7, entry ID 42.
var newResponse = new Response(formattedText, destinationEntry);
var newResponses = new List<Response>(responses);
newResponses.Add(newResponse);
base.ShowResponses(subtitle, newResponses.ToArray(), timeout);
}
}
But if I reload this method, then it will be called every time it needs to show the responses, right? If yes, then this is not exactly what I need. Basically, I can create a "ShowGeneratedResponse" method or something like that. But the question remains how to call it if it is in the StandardUI class. Are there any ways to create additional nodes through CustomScript?
Hm, this tick happened on start of play mode, right?Tony Li wrote: ↑Wed Nov 02, 2022 1:34 pm > Are there any ways to create additional nodes through CustomScript?
Yes. First, tick the Dialogue Manager's Other Settings > Instantiate Database. This will create an in-memory copy of the dialogue database instead of directly using the dialogue database asset file. Now you can change it as much as you want. You can add new dialogue entries (use Template.CreateDialogueEntry() and add it to the conversation's dialogueEntries list) and link them by updating the parent entry's outgoingLinks list.
Code: Select all
public void CreateResponseTree(List<Narrator> narrators)
{
int i = 0;
foreach (Narrator narrator in narrators)
{
CreateReply(++i);
}
}
private void CreateReply(int i)
{
var conversationID = DialogueManager.currentConversationState.subtitle.dialogueEntry.conversationID;
int nodeID = DialogueManager.currentConversationState.subtitle.dialogueEntry.id;
var template = Template.FromDefault();
Conversation conversation = DialogueManager.masterDatabase.GetConversation(conversationID);
var startNode = DialogueManager.currentConversationState.subtitle.dialogueEntry;
var responseNode = template.CreateDialogueEntry(template.GetNextDialogueEntryID(conversation), conversation.id, string.Empty);
responseNode.ActorID = 1;
responseNode.ConversantID = 2;
responseNode.DialogueText = $"Approach a tavern visitor #{i}";
conversation.dialogueEntries.Add(responseNode);
var link = new Link(conversation.id, nodeID, conversation.id, responseNode.id);
startNode.outgoingLinks.Add(link);
responseNode.userScript = "[Variable[\"NarratorType\"] = \"0\"]";
}