Get subtitle lines without starting conversation

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
pmand
Posts: 15
Joined: Wed Mar 01, 2023 1:09 pm

Get subtitle lines without starting conversation

Post by pmand »

How can I get subtitle lines (strings) from a conversation without starting a conversation?
For example, I want to get the second line of "Conversation_A" (just the string).
Can I do this via script? Thanks!
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Get subtitle lines without starting conversation

Post by Tony Li »

Hi,

Yes, here are two ways:

1. If you only need the text:

Code: Select all

Conversation conversation = DialogueManager.masterDatabase.GetConversation("Conversation_A");
DialogueEntry startEntry = conversation.GetFirstEntry();
DialogueEntry secondEntry = conversation.GetDialogueEntry(startEntry.outgoingLinks[0].destinationDialogueID);
string text = FormattedText.Parse(secondEntry.currentDialogueText);
Debug.Log($"Second entry: {text}");
2. If you need to process all the logic:

Code: Select all

model = new ConversationModel(DialogueManager.masterDatabase, "Conversation_A", null, null, true, null);
var response = model.firstState.hasNPCResponse ? model.firstState.firstNPCResponse : model.firstState.pcResponses[0];
var secondState = model.GetState(response.destinationEntry);
Debug.Log($"Second entry: {secondState.subtitle.formattedText.text}");
pmand
Posts: 15
Joined: Wed Mar 01, 2023 1:09 pm

Re: Get subtitle lines without starting conversation

Post by pmand »

Awesome! Thanks, Tony!
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Get subtitle lines without starting conversation

Post by Tony Li »

Glad to help!
Post Reply