Adding an Outline to a TextMeshPro Text

Viewed 11830

Good day, I want to add an outline to my textmeshpro, but the Outline component doesn't seem to work. I also tried the outline settings on the inspector, but it edits all textmeshpro in mys scene. I want to have different outline for every game object that uses textmeshpro.

3 Answers

You can try setting it programmatically:

void Awake()
{
    TextMeshPro textmeshPro = GetComponent<TextMeshPro>();
    textmeshPro.outlineWidth = 0.2f;
    textmeshPro.outlineColor = new Color32(255, 128, 0, 255);
}

I have had issues with TextMeshPro and some fonts before, though, which I haven't been able to fix and I could never find the root cause.

That seems to be the normal behaviour of the component, because the material instance is the same for all the components.

http://digitalnativestudios.com/forum/index.php?topic=630.0

If you change the material you can check that the outline then applies individually:

enter image description here

If you want the exact same material in all your components, which is the desirable thing, I would duplicate the desired font and material in editor, and add one different material instance to each of the components.

Related