Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Bug TextMeshPro and TextMeshProUGUI in one scene

Discussion in 'UGUI & TextMesh Pro' started by Epsilon_Delta, Sep 23, 2020.

  1. Epsilon_Delta

    Epsilon_Delta

    Joined:
    Mar 14, 2018
    Posts:
    26
    Hello,

    I found out that I am unable to have TextMeshPro and TextMeshProUGUI with the same material (same instance) in the same scene at the same time. [unity_GUIZTestMode] is somehow set by them and that can cause wrong order of rendering in canvas (TextMeshProUGUI text was not visible at all).

    The bug is, that everything was fine in the editor, the problem only surfaced when I built an .apk and ran it on Android. So there is a discrepancy in the behavior in the editor (no ZTest problem) and in the Android. Tested in Unity 2019.3.6

    If requested, I can file a bug report.
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    4,974
    This behavior is somewhat timing and hardware related along with potential batching where it might be fine on some platform in some cases but in reality, it is not and only appears to be fine due to luck.

    Sharing the same material between these two renderers (MeshRenderer and CanvasRenderer) where they have difference ZTest requirements and thus fighting over it is just an issue waiting to happen. The solution is to use a different set of material presets for each set of components. That is the correct way to avoid the issue for certain.
     
    Epsilon_Delta likes this.
  3. Epsilon_Delta

    Epsilon_Delta

    Joined:
    Mar 14, 2018
    Posts:
    26
    Stephan_B, thanks for clarification. In the hindsight, yes you are completely right. However, developers unaware of this are doomed to spend some time debugging it (same as me). I wonder if there is a convenient way to communicate this? Maybe a warning in the console or somewhere else. But maybe it's really not responsibility of TMP to warn developers about this and should be handled by other system or not at all.

    Anyway, thank you once again for the reply.
     
    Last edited: Sep 25, 2020
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    4,974
    This is something that most certainly needs to be better documented / added to some FAQ.

    In terms of a warning, I think this is something that should be handled on the Graphic / Rendering side as this behavior could happen with any material that would be shared between a CanvasRenderer, MeshRenderer and possibly SpriteRenderer. But nonetheless a warning or some way to alert that use of this potential issue would be nice.
     
    JimmyCushnie and Epsilon_Delta like this.
unityunity