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?
If you are using a combination of and 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 text objects and another for the UI / Canvas related text objects.
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?
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.
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
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.