Need help to show subtitle regardless if there is no text

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
GarlandChaos
Posts: 18
Joined: Wed Aug 14, 2024 3:06 pm

Need help to show subtitle regardless if there is no text

Post by GarlandChaos »

Hi!
I'm using the asset and finding it very handy so far.
However, I'm facing a problem to customize it according to my project's requirements.
I needed to show only images in some speech bubles and this was solved easily by installing this package:
https://www.pixelcrushers.com/phpbb/vie ... php?t=7931

Now, I want to only show the images, but if I left the Dialogue Text Field empty in a given dialogue node, the subtitle doesn't show. I managed to discover that commenting the following lines from the StandardUISubtitleControls.ShowSubtitle(Subtitle subtitle) method the problem is solved.

Code: Select all

else if (string.IsNullOrEmpty(subtitle.formattedText.text))
{
    HideSubtitle(subtitle);
}
With that, I thought of creating subclasses of the StandardUISubtitleControls, StandardUIDialogueControls and StandardDialogueUI classes. However when creating a subclass of StandardUISubtitleControls and trying to override the ShowSubtitle(Subtitle subtitle method) I'm faced with errors of missing fields and methods because the superclass have them as private. What is the best approach to solve my original problem (show dialogue UIs regardless of having or not an empty dialogue text)?
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Need help to show subtitle regardless if there is no text

Post by Tony Li »

Hi,

That's unfortunately a limitation of how the standard dialogue UI script is implemented -- but it's not an insurmountable limitation!

You could make a subclass of StandardDialogueUI that bypasses the call to StandardUISubtitleControls.ShowSubtitle() but, depending on your requirements, an easier way might be to:

1. Set your Dialogue Text to a string such as "[blank]".

2. Make a subclass of StandardUISubtitlePanel. Override the SetSubtitleTextContent() method to show a blank string if Dialogue Text is [blank]:

Code: Select all

public class MySubtitlePanel : StandardUISubtitlePanel
{
    protected override void SetSubtitleTextContent(Subtitle subtitle)
    {
        if (subtitle.formattedText.text == "[blank]") subtitle.formattedText.text = string.Empty;
        base.SetsubtitleTextContent(subtitle);
    }
}
GarlandChaos
Posts: 18
Joined: Wed Aug 14, 2024 3:06 pm

Re: Need help to show subtitle regardless if there is no text

Post by GarlandChaos »

Whoa, that was fast! :)

Thank you for the solution, since I had already created a subclass of StandardUISubtitlePanel I implemented your [blank] string solution and it's working :D
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Need help to show subtitle regardless if there is no text

Post by Tony Li »

Glad to help!
Post Reply