0

Using TextMeshPro, I would need to apply color to a specific section of the text but at the same time the default text has material color applied.

string text = "Here is default text with brown text\u003Ccolor=#4186FC>Blue text here\u003C/color>"

The problem is that the final result is the multiplication of both color and then the blue part resolves as almost black. If material color is white then no problem.

Would there be a way to cancel the material on this part without making two different text objects?

fafase
  • 467
  • 3
  • 10

1 Answers1

1

You are going to want to use Rich Text. For your example you'd want to use the <color> tag. Here's how it would look

string text = "Here is default text with brown <color=#4186F>Blue text here</color>"

There's a bunch of other parts of the text you can change in the same text field using these tags, so be sure to read into the link.

TEEBQNE
  • 6,104
  • 3
  • 20
  • 37
  • I actually have rich text on. My text also has the tag like you show, just written with unicode value. I guess the solution is to apply both colors to the text and no material. – fafase Jun 07 '21 at 15:16
  • @fafase Oh sorry I misunderstood what you were saying. Yea do not change the `Material` color of the text as that changes the shader tint color. You want to change the `Vertex Color` on the actual `TextMeshPro GUI` component. For whatever reason, I assumed the Unicode alternative was just not working. Why do you want to apply a material? – TEEBQNE Jun 07 '21 at 15:26
  • It's just coz we have those list of premade materials for a given font made by the artists and I was about to use one of them. But since it is just a brown color and then blue color, it occurred to me that I could just apply the tag to both parts. – fafase Jun 07 '21 at 15:29
  • If you have texttexttext, tho you'd want to set the base vertex color to brown. That way everything by default is the brown color and you can use the tags for the blue exception. If the only change the material brings is color then use vertex coloring with the embedded tags. – TEEBQNE Jun 07 '21 at 15:38