Changing text color for individual lines

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
lee5lee
Posts: 3
Joined: Fri Jun 14, 2019 7:06 am

Changing text color for individual lines

Post by lee5lee »

My question is, how to change text color for individual lines, for example making a line in red color, no matter what actor is saying it. How to add different colors to different menu options?
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Changing text color for individual lines

Post by Tony Li »

Hi,

There are two ways:

1. You can use rich text codes. Example:
  • Dialogue Text: "<color=red>[Intimidate the villager.]</color>"
You can do the same with Menu Text.

2. Or you can use [em#] emphasis tags. Example:
  • Dialogue Text: "[em1][Intimidate the villager.][/em1["
The advantage of emphasis tags is that their appearances are set in the Dialogue Editor's Database section. If you decide that you want all [em2]...[/em2] text to be a different color, you can change the info just once in the Database section. You don't have to edit every single node that uses a rich text code.
davegagne
Posts: 17
Joined: Mon Nov 22, 2021 10:26 pm

Re: Changing text color for individual lines

Post by davegagne »

Hi Tony

I discovered the emphasis tags through this post. Amazing stuff ! I was about to do something manually and it sounded like an unscalable nightmare. The emphasis tags is a much cleaner solution that's much easier to maintain.

I managed to test it on a few words within a line, however the underline box does not seem to work. Is there anything that needs to be enabled to allow underline to work with emphasis tags?

Thanks !

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

Re: Changing text color for individual lines

Post by Tony Li »

Hi Dave,

Use TextMesh Pro or Super Text Mesh. (See TextMesh Pro Support.) Unity UI Text doesn't support underline.
davegagne
Posts: 17
Joined: Mon Nov 22, 2021 10:26 pm

Re: Changing text color for individual lines

Post by davegagne »

Hi,

We are already using TextMeshPro.

I'm attaching the Emphasis settings as well as the TestMeshPro component. Is there anything wrong I'm not seeing?

Thanks again !

Dave
Attachments
emphasis-tags-02.JPG
emphasis-tags-02.JPG (30.04 KiB) Viewed 2680 times
emphasis-tags.JPG
emphasis-tags.JPG (20.93 KiB) Viewed 2680 times
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Changing text color for individual lines

Post by Tony Li »

Hi Dave,

Please use this patch:

DS_EmphasisTagPatch_2022-02-17.unitypackage

This is also updated in the upcoming version 2.2.26.
davegagne
Posts: 17
Joined: Mon Nov 22, 2021 10:26 pm

Re: Changing text color for individual lines

Post by davegagne »

Great,

I'll try that!

Dave
davegagne
Posts: 17
Joined: Mon Nov 22, 2021 10:26 pm

Re: Changing text color for individual lines

Post by davegagne »

Works brilliantly !

Thanks again,

Dave
Post Reply