How to fix Text Mesh Pro showing in scene view but not in game view
I recently had the problem that for whatever reason my Unity game stopped displaying certain texts. Within the scene view, the text was visible, but within the game view of the running game some of the texts disappeared. Even more strange, it was the same prefab used throughout the game and even on the same panel, some texts where visible, some not.
After doing some searching, there were solutions from recreating the prefab or the font files. Last one did work, but it doesn't look like a real solution to me. After searching a bit more, I've found this post from June 2018 explaining that this could happen if you use TextMeshPro and TextMeshProUGUI within the same scene.
If you are using a mixture of normal TextMeshPro objects and TextMeshProUGUI objects which happen to share the same material preset, this can produce this behavior as the MeshRenderer and CanvasRenderer systems are fighting over the ZTest on these objects. If that is the case, the solution is to have a set of Material Presets for the normal text objects which are in worldspace and another set for the objects using the canvas system.
And that's exactly the correct problem description and solution. In my scene, I had both objects. So the solution is to create a new material preset:
Rename it to something that you know, that this preset is either used for all TextMeshPro objects or all TextMeshProUGUI objects. And then assign that material to all objects:
It does not matter which one you change, just make sure that all non UGUI objects use a different material than the UGUI objects.
Funny thing is, that the problem didn't arise the moment I've added both objects to the scene, but somewhat later in time.