Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

TextMesh Pro Text is behind Tilemap (Sorting Issue)

Discussion in 'UGUI & TextMesh Pro' started by NuKeR2k, Nov 28, 2022.

  1. NuKeR2k

    NuKeR2k

    Joined:
    May 17, 2015
    Posts:
    1
    Hi all,

    I'm using Unity's built-in Tilemap in a 2D URP scene. After adding a TextMesh Pro - Text to my scene the text will be displayed behind my tile map as the following demo screenshot shows:

    Screenshot from 2022-11-28 17-19-12.png
    The text itself is using the TextMeshPro/Distance Field Overlay shader.

    The tile map settings on the other hand are as follows:

    Screenshot from 2022-11-28 17-24-13.png

    The tile map's sorting layer is set to "Layer 1". If I instead switch the tile map's sorting layer to "Default" the text will be displayed correctly on top of the tile map. However, I need to use sorting layers for my tile map(s). So is there a way to handle the sorting of the text mesh pro?

    I already tried some other TMP shaders but as far as I know the Distance-Field-Overlay shader already is supposed to draw the text on top (of everything?).

    Does anyone have an idea what I am doing wrong here or maybe if it is a bug/unsupported feature?

    Thanks in advance

    Edit:

    You can control the sorting layer via code by modifying MeshRenderer's sorting like this:

    Code (CSharp):
    1.  
    2. _meshRenderer.sortingLayerName = _sortingLayerName;
    3. _meshRenderer.sortingOrder = _sortingOrder;
    4.  
    Is there a way to allow the text rendered on top tile map's by default without manipulating MeshRenderer's sorting?
     
    Last edited: Nov 28, 2022
  2. tabandija

    tabandija

    Joined:
    Apr 26, 2022
    Posts:
    4
    In the TextMeshPro Text component, select "Extra Settings". There you will find the the Sorting Order field. I set it to a very high number.