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.
  2. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

TextMesh Pro not rendering on Game View, but yes on Scene view

Discussion in 'UGUI & TextMesh Pro' started by ElChileVengador, Aug 19, 2018.

  1. ElChileVengador

    ElChileVengador

    Joined:
    Feb 4, 2013
    Posts:
    23
    Hi everybody,

    I'm having a weird issue with TextMeshPro. I have a gameobject with a text Mesh that doesn't seem to be rendering on the game screen, even when it does so in the scene view. I'm using a perspective camera and do have text mesh UI elements in the same scene. I thought it might be a issue with the materials, but even using different fonts and materials I get the same error. I've double checked I'm using the correct text component (i.e. not accidentally using the UI one) and that the object is inside the camera fulcrum. Has anyone encountered something similar before?

    I'm attaching a screenshot to better explain what I mean. As you can see, the text on the left does not appear on the game view. Any thoughts?

    In advance, thanks.
     

    Attached Files:

  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,572
    If you are using a combination of <TextMeshPro> and <TextMeshProUGUI> components in the same scene where these objects happen to share the same material preset, you will end up with the Mesh Renderer and Canvas Renderer fighting each other over control of the ZTest on the material.

    The solution is to have two different sets of Material Presets. One for the normal <TextMeshPro> text objects and another for the UI / Canvas related text objects.

    See the following post / thread.
     
    ElChileVengador likes this.
  3. ElChileVengador

    ElChileVengador

    Joined:
    Feb 4, 2013
    Posts:
    23
    That did the trick! Thanks Stephan.

    A maybe related issue arose though. I created a new material based on the default liberation Sans font, however when placed on the scene, I get the result shown. The font in the game view is replaced by squares. If I change the shader from Distance Field to Bitmap, it gets resolved.

    For my purposes this is fine, but out of curiosity, would you happen to know why Distance field doesn't work?

    Thanks! Screen Shot 2018-08-19 at 7.34.49 PM.png
     
    MSOTech likes this.
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,572
    White squares are indicative of a potential non-uniform scale. So make sure the X, Y and Z scale of the text object are the same.

    It is also possible to get the same white square if the Scale X and Scale Y in the debug section of the material inspector are set to zero.

    Lastly, if the reference to the font atlas texture is lost or pointing to the wrong font atlas texture, you could get white squares in the UI.

    When creating new Material Presets, make sure that you are using the Context Menu option - "Create Material Preset" as seen below.

    upload_2018-8-19_21-41-47.png

    If your original font asset was an SDF font asset, you need to keep using SDF shaders. If the Material Presets were created with the context menu option, the same shader as the source material will be used.
     
    MSOTech and tommyvisic like this.
  5. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    368
    Where did you get your world map?
     
  6. ElChileVengador

    ElChileVengador

    Joined:
    Feb 4, 2013
    Posts:
    23
  7. yelly314

    yelly314

    Joined:
    Sep 18, 2022
    Posts:
    1
    I did this but it didn't work. I also only have one text element, so I didn't think it would be a problem, yet it still was.
     
unityunity