Search Unity

TextMesh Pro TMP SpriteAsset with custom material instantiation at runtime not working?

Discussion in 'UGUI & TextMesh Pro' started by Yandalf, Sep 3, 2022.

  1. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    Hello!

    I'm creating a system where I'm spawning TMP elements (non-gui) at runtime and set them up with a few settings. The result should be a TMP element displaying a sprite from a given SpriteAsset using a material set in that SpriteAsset. This works fine when using the default TMP Sprite shader for this material, but when I try this with a material using TextMeshPro/Mobile/Distance Field the resulting element is a transparent full quad. If I then edit the text in the TMP element, the sprite will show up correctly.
    Any idea how I could make sure the sprite will be correct immediately after spawning? I already tried using ForceMeshUpdate, but this had no visual effect.