Page 1 of 1

Get Conversation text only

Posted: Thu Jun 27, 2024 8:51 am
by windwalking
Hello!

I have a part of my game where just one line shows up in the middle of the screen. I want to get that random text from a similar structure as barks. I guess my question is, can I get only the string from a conversation directly in script?

Re: Get Conversation text only

Posted: Thu Jun 27, 2024 10:33 am
by Tony Li
Hi,

Yes, you can create a ConversationModel. Assuming the line is assigned to an NPC:

Code: Select all

var model = new ConversationModel(DialogueManager.masterDatabase, "conversation title", null, null, true, null);
var state = model.GetState(model.firstState.firstNPCResponse);
Debug.Log("Text is " + state.subtitle.formattedText.text);