Greying out dialogue lines in accumulative text boxes?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
marafrass
Posts: 36
Joined: Thu Jan 16, 2020 1:32 pm

Greying out dialogue lines in accumulative text boxes?

Post by marafrass »

Heya Tony!

I'm using a heavily modified version of the WRPG Template in my project, accumulating subtitle lines as the dialogues progress.

I'd like to grey out or reduce opacity on all previous lines in the textbox, to make the current one a little clearer. Is there a simple way of increasing opacity on a line after it has been showed and "continue" has been hit? (Preferably something that would let me retain the color of the subtitle line itself!)

Something like this:

Code: Select all

This Speaker: Semi-transparent
This Speaker: Semi-transparent
This Speaker: Semi-transparent too

Current Spoken Line: In full, spectacular color.
EDIT:
While I'm asking, I thought I'd drop another quick question as well:
Is there an already implemented way of separating Subtitles from Response Options? Essentially, I'd like to prevent accumulated dialogue from going past the halfway point of the Scroll Rect, reserving the lower part for Response Options.

Code: Select all

Speaker: This upper half would be exclusive to spoken lines

Speaker: This upper half would be exclusive to spoken lines

Speaker: This upper half would be exclusive to spoken lines

Speaker: This upper half would be exclusive to spoken lines

(Anything Below this is reserved for Response Options, whenever those appear.)


1. Option, if currently relevant
2. Option, if currently relevant
3. Option, if currently relevant

User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Greying out dialogue lines in accumulative text boxes?

Post by Tony Li »

Hi,

I'll bounce around a few ideas.

To always reserve the bottom half of the dialogue panel for the response menu, move it out of the Scroll Rect and set its size.

To grey out previous subtitle text, use two text elements (or, better yet, TextMeshProUGUI elements). The top one will hold all of the accumulated old lines. The bottom one will show the current subtitle.

Those two changes will make the dialogue UI look something like this:

marafrass1.png
marafrass1.png (45.27 KiB) Viewed 369 times

On the top subtitle text element (which will hold the old lines), don't add a typewriter effect. Also untick Rich Text, and set the color to grey.

Then untick the subtitle panel's Accumulate Text checkbox, and manually accumulate text instead. If you've already subclassed StandardUISubtitlePanel, override the SetContent method. Otherwise add a new script that has an OnConversationLine method that adds the previous line to the accumulated old lines. Something like:

Code: Select all

public TextMeshProUGUI oldText; //<--Assign in inspector.
private string currentLine = null;
void OnConversationStart(Transform actor)
{
    currentLine = null; // Initialize at start of conversation.
}
void OnConversationLine(Subtitle subtitle)
{
    if (!string.IsNullOrEmpty(currentLine))
    {
        if (!string.IsNullOrEmpty(oldText.text)) oldText.text += "\n";
        oldText.text += currentLine;
    }
    currentLine = subtitle.formatted.Text.text;
}
marafrass
Posts: 36
Joined: Thu Jan 16, 2020 1:32 pm

Re: Greying out dialogue lines in accumulative text boxes?

Post by marafrass »

Thanks for your reply and your ideas! It solved pretty much all the issues I was having. Hugely appreciated, as always.
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Greying out dialogue lines in accumulative text boxes?

Post by Tony Li »

Glad to help!
Post Reply