Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question TextMeshPro - Proper way of adding text shadow(lower border)

Discussion in 'UGUI & TextMesh Pro' started by qLate, Nov 16, 2023.

  1. qLate

    qLate

    Joined:
    May 3, 2019
    Posts:
    13
    In my current project, most of the text is displayed with shadow:
    upload_2023-11-16_16-41-26.png

    I achieved this effect by spawning the same text, but with darker color and offset and it works.

    However it's obvious that this approach is bad for performance, especially for my project, where a lot of text objects are being spawned and destroyed constantly. And it's a bit annoying, because instead of just a regular TMPro component there's now a gameobject with custom script and 2 children -- main text and border text.

    I've already looked into some of the TMPro features, such as underlay, but there's a problem. The border is created of a single color, while I need it to have a bit darker color then the symbol which it was created for.

    Here's an example of text with color tags and underlay enabled:
    upload_2023-11-16_16-54-58.png

    Therefore I've been looking for a better solution -- maybe a shader, or some kind of vertex manipulations to achieve similar effect without the need of instantiating new objects.
     
    Last edited: Nov 16, 2023