Search Unity

TextMesh Pro Mixing 2D and 3D text caused 2D text to disappear

Discussion in 'UGUI & TextMesh Pro' started by Peter77, Feb 10, 2020.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    This is kind of a bug, but I'm unable reproduce it in an isolated project and I can't submit the actual project, so I leave a message here for you, hoping you have an idea how you can fix this behavior. Perhaps it's also "by design", who knows.

    I have multiple 3D texts via the "Text Mesh Pro" Component and multiple 2D texts via the "Text Mesh Pro UGUI" Component in the game. All texts point to the same "Font Asset" and "Material Preset".

    This caused all 2D texts to disappear.

    Using a separate "Material Preset" for 2D texts works around the problem.

    I guess the 2D UGUI elements perhaps got batched/transformed together with 3D texts, which caused them to disappear, but this is just a guess.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    This is not a bug per se but rather a byproduct of having (2) two different renderers / system fighting over the same material.

    More specifically, the MeshRenderer used by the <TextMeshPro> object and the CanvasRenderer used by the <TextMeshProUGUI> object have different ZTest requirements and batch differently. Since these text objects share the same material, these two renderers / systems end up fighting over this material.

    The solution is to use a different set of Material Presets for the <TextMeshPro> objects and another for the <TextMeshProUGUI> objects.
     
    Peter77 likes this.