Page 1 of 1

Changing text color for individual lines

Posted: Fri Nov 20, 2020 3:43 am
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?

Re: Changing text color for individual lines

Posted: Fri Nov 20, 2020 7:44 am
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.

Re: Changing text color for individual lines

Posted: Thu Feb 17, 2022 9:26 am
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

Re: Changing text color for individual lines

Posted: Thu Feb 17, 2022 9:36 am
by Tony Li
Hi Dave,

Use TextMesh Pro or Super Text Mesh. (See TextMesh Pro Support.) Unity UI Text doesn't support underline.

Re: Changing text color for individual lines

Posted: Thu Feb 17, 2022 9:44 am
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

Re: Changing text color for individual lines

Posted: Thu Feb 17, 2022 11:02 am
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.

Re: Changing text color for individual lines

Posted: Thu Feb 17, 2022 11:05 am
by davegagne
Great,

I'll try that!

Dave

Re: Changing text color for individual lines

Posted: Thu Feb 17, 2022 11:52 am
by davegagne
Works brilliantly !

Thanks again,

Dave