Page 1 of 1

Get subtitle lines without starting conversation

Posted: Thu May 23, 2024 9:21 pm
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!

Re: Get subtitle lines without starting conversation

Posted: Fri May 24, 2024 8:19 am
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}");

Re: Get subtitle lines without starting conversation

Posted: Fri May 24, 2024 1:21 pm
by pmand
Awesome! Thanks, Tony!

Re: Get subtitle lines without starting conversation

Posted: Fri May 24, 2024 2:15 pm
by Tony Li
Glad to help!