Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

TextMeshPro UI with material does not show on iOS

Discussion in 'UGUI & TextMesh Pro' started by ETGgames, Jul 15, 2021.

  1. ETGgames

    ETGgames

    Joined:
    Jul 10, 2015
    Posts:
    101
    If I create a duplicate material and use that, it works. I have checked everywhere for possible cases of regular TextMeshPro on the scene (not TMP UGUI/UI) and I can't find any, so it isn't to do with that. It's just iOS that it doesn't show, it works fine on mac and android builds both il2cpp and mono. I have the same problem with another font too, but that works randomly, the main font never shows. What do I do?
     
    Last edited: Jul 15, 2021
  2. Epsilon_Delta

    Epsilon_Delta

    Joined:
    Mar 14, 2018
    Posts:
    258
    Your description of the problem is not completely clear, but I had a similar problem so I will share my knowledge (which comes from Stephan_B). You cannot have TextMeshPro and TextMeshProUGUI element in one scene at the same time with the same material. UGUI does something with Z ordering of the material's shader (don't remember exactly). Moreover the results are inconsistent over the platforms, on some platform the problem manifests on some others not (depends on some circumstances). Solution is your first sentence: use separate materials for TextMeshPro and TextMeshProUGUI.
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Do you happen to be using a mixture of normal <TextMeshPro> and UI <TextMeshProUGUI> objects in the same scene where these objects would share the same font asset and material preset?

    As @Epsilon_Delta points out, this can be an issue on some devices as it is timing related. See the following thread for a more complete explanation of the issue.
     
  4. ETGgames

    ETGgames

    Joined:
    Jul 10, 2015
    Posts:
    101
    Aha! I found where I had objects with regular textmeshpro on! The objects were stored in a collection on a static singleton that had just been loaded from resources.load, that's why I couldn't find them in the scene...

    However, simply just creating a new material was not good enough. It partially solved the problem - I can now see the UI text, but once I instantiate the regular text to the scene, the UI text disappears, even though they are using separate materials. The only solution was to create an entirely new atlas...which I guess is better than nothing.

    Is there anything special I would have to take care of when duplicating the material - I just clicked create material preset on the existing one and used that (and it didn't work, as described above). Also, how does this whole concept apply to input fields that use TMP? Do we treat it as UGUI?
     
    Last edited: Jul 15, 2021
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Creating and making sure that all normal <TextMeshPro> objects in world space are using their own material preset vs. the <TextMeshProUGUI> objects should do the trick. If that didn't work, you might still have an overlap as the TMP Input Field does count as a <TextMeshProUGUI> text object.