Use custom field value for subtitle text

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Ptolemy
Posts: 2
Joined: Wed Jun 04, 2025 5:33 pm

Use custom field value for subtitle text

Post by Ptolemy »

Hey Tony,

How can I use a custom field to display conversation text to the dialogue panel? I'm using the WRPG template because I need the conversation/response history to remain visible. Right now I've got a custom string field, "Body" and with my character dialogue as its value. I found this topic and am using your example code as a starting point:

https://pixelcrushers.com/phpbb/viewtop ... tle#p43226

However, upon triggering the conversation at runtime, the panel remains blank.

I'd love to get the pattern down for using fields/values to update text objects and sprites throughout the dialogue canvas hierarchy. Replacing the menu/dialogue text fields with custom ones seemed like the best place to start.
User avatar
Tony Li
Posts: 23278
Joined: Thu Jul 18, 2013 1:27 pm

Re: Use custom field value for subtitle text

Post by Tony Li »

Hi,

What are you putting into the dialogue entry's Dialogue Text and/or Menu Text fields? Those fields are for dialogue text (and optionally response menu text).

To show additional text that's not dialogue text, you can create a custom field. For example, let's say you've added a custom Text field named "Mood" where you enter the current mood of the speaker of this dialogue entry:

mood1.png
mood1.png (73.71 KiB) Viewed 1070 times

And you've added a Mood text UI element to your dialogue UI:

mood2.png
mood2.png (84.7 KiB) Viewed 1070 times

Then add a script with an OnConversationLine(Subtitle) method to your Dialogue Manager. Something like:

Code: Select all

public TextMeshProUGUI moodText; // Assign in inspector.

void OnConversationLine(Subtitle subtitle)
{
    // This method is called before each subtitle is shown.
    // Also update the Mood text:
    var mood = Field.LookupValue(subtitle.dialogueEntry.fields, "Mood");
    moodText.text = mood;
}
Ptolemy
Posts: 2
Joined: Wed Jun 04, 2025 5:33 pm

Re: Use custom field value for subtitle text

Post by Ptolemy »

What are you putting into the dialogue entry's Dialogue Text and/or Menu Text fields? Those fields are for dialogue text (and optionally response menu text).
Currently they're empty, I was hoping to use a custom field to do what they do. I was hoping to display dialogue text with a header of text above it. In other words, I aim to display a title above each dialogue that isn't a response.

The header font needs be a larger size than the body/dialogue text.

Header
Body

Response Buttons

I guess what I'm trying to do is create a custom formatted subtitle to push to the dialogue panel. Hoping to do this in a script attached to a separate manager game object.

EDIT: thanks for the example using the Mood field. That is exactly what I needed to affect those other text/sprite objects in the panel hierarchy. Is it possible to use OnConversationLine(Subtitle subtitle) in a script not attached to the DialogueManager game object? I'd like to see the script inspector at runtime. Thanks again!
User avatar
Tony Li
Posts: 23278
Joined: Thu Jul 18, 2013 1:27 pm

Re: Use custom field value for subtitle text

Post by Tony Li »

Hi,

You can still see the inspector of scripts on the Dialogue Manager at runtime. In the Unity editor's play mode, you can find the Dialogue Manager in the DontDestroyOnLoad scene.

The Dialogue System calls OnConversationLine() on these recipients.

I'm still not quite sure what you're doing with the Dialogue Text field. You might want to use Dialogue Text for the body text and a custom "Header" field for the header text.
Post Reply