Search Unity

[SOLVED] How to get TextMeshPro to always render on the top of everything else?

Discussion in 'UGUI & TextMesh Pro' started by scmulagah, Nov 21, 2018.

  1. scmulagah

    scmulagah

    Joined:
    Jun 27, 2018
    Posts:
    14
    I am trying to get a 3D TextMeshPro object to render on top of everything else. But in the extra settings of the object, sorting layer, only shows DEFAULT, and doesnt allow me to select other layer.
     
    orgelvarg likes this.
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The other layers (that were created by you in the Unity layer editor) should show up in this list of available layers.

    To have <TextMeshPro> text object always render on top of everything else, you can always use the TextMesh Pro - Mobile - Distance Field Overlay shader.
     
  3. scmulagah

    scmulagah

    Joined:
    Jun 27, 2018
    Posts:
    14
    Thanks for the tips, got it to work by just changing the shader.

    Unfortunately, the Sorting layer still only shows, DEFAULT, even though i have some custom layer that i have used.

    asdasd.PNG
     
    Aryyma likes this.
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Did you add those in the Sorting Layer section?

    upload_2018-11-21_23-42-59.png

    upload_2018-11-21_23-43-11.png

    These are showing up as expected on my end.
     
    JohnnyConnor, orgelvarg and scmulagah like this.
  5. scmulagah

    scmulagah

    Joined:
    Jun 27, 2018
    Posts:
    14
    Ah.. gotcha, setted it up wrongly then. Was thinking of layers, not sorting layers.
    Thanks Stephan
     
  6. MFKJ

    MFKJ

    Joined:
    May 13, 2015
    Posts:
    264
    I am changing overlay shader on runtime when user select text overlay option. It is working fine but with a problem, the outline is not visible in overlay shader. meanwhille it is correctly working in the editor. I am using webgl unity 2019.1
     
    rnrgjs1123 likes this.
  7. rnrgjs1123

    rnrgjs1123

    Joined:
    Mar 11, 2019
    Posts:
    1
    I didn't know there was an overlay shader, but I solved it thanks to you.
    I saw the reply that came up today
     
  8. MFKJ

    MFKJ

    Joined:
    May 13, 2015
    Posts:
    264
    Here is the short demo video, you can either use overlay shader for always render on top. Or distance field shader for normal render.
     
    Last edited: Jun 11, 2020
    bymuto, Anisoropos, octav88 and 5 others like this.
  9. professor1453

    professor1453

    Joined:
    Nov 24, 2018
    Posts:
    1
    I was having this same problem: my TextMeshPro text was always showing up behind any everything other than something on the default or background layer, and there's no way to change layers on the TMPro component or Canvas Renderer (at least none that I could see). Changing the shader didn't help. Changing the z-coordinate didn't help. I finally realized I needed to put my text on a world-space canvas and set the sorting layer *on the canvas*. I created a new sorting layer call "Dialog Text," put it last in the list of sorting layers, and applied it to the canvas. Now the TMPro text is visible above all other graphic objects.
     
    Sara2428, HarisKap, blowe877 and 2 others like this.
  10. rc82

    rc82

    Joined:
    Jan 28, 2020
    Posts:
    44
    Thanks! This helped out!
     
  11. deadlycrow

    deadlycrow

    Joined:
    Feb 10, 2014
    Posts:
    166
    Does this work in HDRP? cause currently when i change it to distance field overlay (mobile too) it just dissappear :/
     
  12. aloften

    aloften

    Joined:
    Aug 25, 2017
    Posts:
    18
    If someone wandered here and did not find this thread helpful, please read my comment. :)

    Ive been messing with this issue for a long time. I randomly find fixes that works for a particular instance but not others. Its quite frustrating. There is NO SORTING LAYER option for me. I mean I specifically have this issue with input fields, but idk, I feel its the same issue.

    Weird thing is the text is visible if you flip the scale to -1 but...well...its backwards. Sometimes things even show with a slight 0.012 y rotation but not with a 0

    I have tried changing the shader to the distance overlay shader, Iver looked for a render queue(which doesnt seem to appear on the materials I see for tmp - and doesnt work on the default unity materials for this field), and Ive tried a whole mess of other things.

    I found 1 solution that works. After creating an input field, there is a child object called "text area." Disableing the "Rect Mask" seems to cause it to work and im not seeing ANY downside from it YET. Im sure that there will be an issue later because...well...its a mask that was intentionally placed there.

    But until I have that issue, this is the solution I will choose..
     
  13. Rand_D

    Rand_D

    Joined:
    Oct 24, 2017
    Posts:
    44
    There are two components: TMP UGUI (the one you described, only usable with canvas and is for UI) and TMP - text which replaces legacy 3d text mesh (you can find mesh renderer component when you create it) This one will have sorting order when you click on Expand Setting. It confuses me as first too.