Text in my script

Announcements, support questions, and discussion for Quest Machine.
Post Reply
EVG
Posts: 27
Joined: Sun Jul 04, 2021 4:55 pm

Text in my script

Post by EVG »

Hello, I apologize if this topic has already been described in the documentation, but it's hard for me to search in a language that is foreign to me. I'm using the Quest Machine, and I probably haven't figured it out well yet. How do I get the text values (Dialogue, Journal, HUD, etc.) in my script?
Example:

public TextMeshProUGUI textHUD = default;
public TextMeshProUGUI textJournal = default;

public ShowText()
{
textHUD.text = ?
textJournal.text = ?
}
User avatar
Tony Li
Posts: 21926
Joined: Thu Jul 18, 2013 1:27 pm

Re: Text in my script

Post by Tony Li »

Hi,

I assume you want to get the text for the quest's current state.

First you need a reference to the quest. For example, you can use QuestMachine.GetQuestInstance():

Code: Select all

Quest quest = QuestMachine.GetQuestInstance("A Quest ID");
Then use Quest.GetContentList():

Code: Select all

List<QuestContent> contentList = quest.GetContentList(QuestContentCategory.HUD);
Every QuestContent has a runtimeText property. So you can get the complete text like this:

Code: Select all

string text = string.Empty;
foreach (QuestContent content in contentList)
{
    text += content.runtimeText + "\n";
}
EVG
Posts: 27
Joined: Sun Jul 04, 2021 4:55 pm

Re: Text in my script

Post by EVG »

This is what I need, thanks
User avatar
Tony Li
Posts: 21926
Joined: Thu Jul 18, 2013 1:27 pm

Re: Text in my script

Post by Tony Li »

Glad to help!
Post Reply