Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    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:
    27
    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

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    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.
     
    Gabe-Tucker and ElChileVengador like this.
  3. ElChileVengador

    ElChileVengador

    Joined:
    Feb 4, 2013
    Posts:
    27
    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
     
    ghostitos and MSOTech like this.
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    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.
     
    Zaddo, MSOTech and tommyvisic like this.
  5. giantkilleroverunity3d

    giantkilleroverunity3d

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

    ElChileVengador

    Joined:
    Feb 4, 2013
    Posts:
    27
  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.
     
    ghostitos likes this.
  8. CassClay

    CassClay

    Joined:
    Mar 21, 2020
    Posts:
    72
    If nothing else works for you or someone else, try to scale your Canvas holding the Text Mesh Pro text, that's what solved not rendering for me, in some mobile resolutions the canvas were probably bigger than the screen itself and if text couldn't fit it did not draw on screen. Also you could make it Scale with Screen Size, you can try getting the Canvas Scaler component and dynamically scale it to the screen size, that would work for all resolutions. I personally added a script to my Canvas that also anchor the Canvas itself to the middle of the screen, it's part of nifty scripts I found online that takes care of keeping the resolution of my scenes consistent for all mobile screen sizes and keep everything within camera view. The reference search in google:
    How to fit your Unity Game on Different Mobile Screen Sizes
     
  9. Zaddo

    Zaddo

    Joined:
    May 19, 2012
    Posts:
    79
    Thanks. This was driving me crazy. I was using an admittedly old version of Calcatz WorldSpaceCanvasUI from the asset store. X and Y scaling was uniform. But Z was set to zero. All have to be identical.