Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. 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

Textmesh Pro disappear during gameplay

Discussion in 'UGUI & TextMesh Pro' started by MarceloSabadini, Jun 20, 2018.

  1. MarceloSabadini

    MarceloSabadini

    Joined:
    Dec 18, 2017
    Posts:
    2
    Hello all,

    In our game, suddenly all Text Mesh Pro UGUI components became transparent.
    That happens in editor, android and iOS, but is way more common in iOS, principally in iPhone X.
    During one time that happen in editor, was notice that the text is only transparent in game view, staying normal in scene. The component went back to normal if the font/material was replaced and nothing changes when a different scene is loaded.
    That error happens more frequently when all the scenes are unloaded and the first scene is loaded again or when some very specific requests are made to the server.
    We are using Unity 2017.4.1f1 and Textmesh pro 1.2.2 but that was also happening with Textmesh pro 1.0.56.0b3.

    Cheers.
    Thanks in advance
     
    burakkurkcu likes this.
  2. FernandoHC

    FernandoHC

    Joined:
    Feb 6, 2018
    Posts:
    325
    Hi Marcelo,

    I had a similar issue some time ago, which resulted in some texts not being displayed depending on the aspect ratio of the device it was on.
    The reason was because the RectTransform for the text object was smaller than the minimum font size on the TextMeshProUGUI component.

    Fixing the size and auto text size adjustments solved the issue.
    To quickly test if that's what is causing the issue you can select Wrappping & Overflow to: Disabled / Overflow.
     
  3. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    4,679
    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.

    Let me know if you have a mixture of these objects in your scene?
     
    clamum, iMancha, hmathiy and 4 others like this.
  4. MarceloSabadini

    MarceloSabadini

    Joined:
    Dec 18, 2017
    Posts:
    2
    Hello Stephan_B,
    In fact we have a mixture of objects using TexmeshPro and TextMeshProUGUI. There are no in the same scene, but sometimes both scenes are loaded.
    I will try to create different material for each type of text and return to you if that works.
    Thanks in advance.
     
  5. burakkurkcu

    burakkurkcu

    Joined:
    Oct 2, 2016
    Posts:
    1
    I can confirm having the same issue, UI texts were disappearing. And I have got mixture of TextMeshPro and TextMeshProUGUI components in my scene. And by creating different materials for each set, issue seems solved for now.

    Thank you Stephan!
     
    Stephan_B likes this.
  6. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    130
    2018.3.8f1
    I am still having trouble with this.
    @Stephan_B So you are saying that the TextMeshPro UGUI objects can all be the same material but the other Unity texts have to or can all have the same of or different materials?
    And by making sure of the separation then the texts will show in the Unity game tab?

    I have a lot of materials to choose from and am trying to make sure I understand what is going on here and if my thinking/efforts are in synch with your solution.

    This post is a year after the previous and am wondering if I am on the correct track. I also updated TMP to 1.4.x
     
    Last edited: Jul 3, 2019
  7. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    4,679
    Which text objects are disappearing?

    Text disappearing when using a mixture of <TextMeshPro> and <TextMeshProUGUI> components where these text object happen to share the same material preset or default material is due to how the Canvas System and Mesh Renderer fight over the ZTest which makes one or the other objects disappear. The solution for that is to make sure you have a separate set of Material Presets for the <TextMeshProUGUI> components and one for the normal <TextMeshPro> components.

    Text disappearing when using UI Text is a new behavior that I have seen lately which is unrelated to TMP.
     
    Last edited: Jul 3, 2019
  8. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    130
    Thanks for responding.
    I have Unity Text and MTP text disappearing. They were working fine the other day. Then the MTPs disappeared and then the Unity texts disappeared. I have flipped through different materials and the results are the same. But at this point I have not totally got the two text type isolated on two different materials. There are Unity canvas button texts that I need to change(I think). But like I stated, this just started to happen. I have everything on the game screen then I pulled in the OVR gazepointer then the canvas buttons. Then boom. The TMPs texts disappeared and now all texts.
     
  9. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    4,679
    Did this issue begin to appear when you upgraded to a newer version of Unity? If so, what version are you using now?
     
  10. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    130
    2018.3.1f8.
    I have had this version since Feburary. It just started the other day.
     
  11. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    4,679
    TMP text objects are independent of UI Text objects so one should not be affecting the other.

    Mixing of <TextMeshPro> and <TextMeshProUGUI> text objects where they share the same material can result in issues.

    If this behavior just started happening with the same version of Unity then we need to figure out what may have changed in your scene.

    Did you just start using a mixture of <TextMeshPro> and <TextMeshProUGUI> components?


    Changes to TMP would not affect UI Text so do you recall making any changes to project settings related to graphics or textures?

    If you are able to reliably reproduce the behavior, please submit a bug report with the project and steps to reproduce it.
     
  12. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    130
    Ugh! It was the canvas switch set wrong. I switched it back to render world space and all the text appeared.
     
    Stephan_B likes this.
  13. diginut

    diginut

    Joined:
    Sep 9, 2019
    Posts:
    1
    This bug is apparently still around; I just experienced it in a scene in which I have a UI (Screen Space Overlay) and also some world-space text overlays with the main camera. I'd been using both TMP and TMPUGUI for a while, but I forgot to update the TMPs to the new font I was using; as soon as I did that, the UI text disappeared!

    The effect is pretty strange; saving the scene would make the text reappear briefly, but as soon as I made any changes or tried to run the game, it would disappear again. Duplicating the materials and using different ones for the worldspace text, as per suggestions several posts up, solved the problem.

    Maybe comment #12 is a different workaround, possibly this only affects screen-space canvases. Didn't try.

    It's literally A/B testable, if I try to switch the TMPs back to the same material I use for TMP-UI, then the UI text disappears, and if I switch it to the duped material, the UI text reappears. Definitely not related to graphic settings or anything of that sort.
     
  14. puetsua

    puetsua

    Joined:
    Feb 28, 2019
    Posts:
    1
    I had the same problem too after I updated to 1.4.1 in 2018.3.14f1 Unity. I found a workaround to avoid the bug if I don't scale my textmeshpro object to zero.
     
  15. burc_sunday

    burc_sunday

    Joined:
    Jan 7, 2020
    Posts:
    3
    I just logged in to say that I had the exact same problem today (I was animating my popup windows from scale 0 to 1)
    and I believe it's safe to consider as a bug of TextMesh Pro. It was really to pinpoint the exact issue until I saw this post. I hope it's fixed soon.
     
  16. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    4,679
    In order for the text to render correctly, the scale of the text object must be uniform (X, Y, Z). This scale is used to compute the SDF Scale which is the relationship between the final scale of the text object and the scale of the glyphs in the atlas texture.

    An incorrect SDF Scale will result in either fuzzy or overly sharp text or white blocks of text. It can result in non visible text but mostly the latter. It is frequent for users who animate the scale of the text object to potentially end up with an incorrect SDF Scale as the text component is unaware of such scale changes. TMP does check every frame if the scale of the text object has changed before the frame is rendered but it is possible for users to change the scale after this check.

    Since animating / scaling of the text object can be implemented in many ways, it is beneficial for me to get reproduction cases to allow to see if an alternative / better implementation might be possible. So please submit bug reports with repro projects as this would be most useful.
     
  17. pmerilainen

    pmerilainen

    Joined:
    Dec 23, 2013
    Posts:
    5
    In my project I did experience following: Screen Space Overlay canvases lost their text content but in World Space and Screen Space Camera canvases text showed correctly.

    This happened when I used Resources.Load() to load a font asset and assigned it to TMP_Text's font property by a scripts; after loading the font and a new scene everything that's in Screen Space Overlay canvases randomly disappeared.

    Workaround for the issue is to use Text Mesh Pro only Screen Space Camera and World Space canvases; for Overlays I used regular Text

    Unity version is 2019.2.21f1
     
    Last edited: Apr 20, 2020
  18. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    4,679
    There is no need to use UI Text as the likely cause of the behavior is using a mixture of <TextMeshPro> and <TextMeshProUGUI> text object where these share the same material.

    As per the following post above:
    When you create a new font asset, it has a default material. As such, two text objects using this same font where one object is in screen space overlay and the other in world space would result in this behavior.

    Again the solution is to use a different set of material presets for these two groups of object.
     
  19. pmerilainen

    pmerilainen

    Joined:
    Dec 23, 2013
    Posts:
    5
    We do have separate materials for both Text Mesh Pro and TextMeshPro UGUI, this had no effect on the disappearing text.

    Please note that the bug happens only on ios with Metal and fonts did disappear when new scene is loaded, so this might be related to pre-baked rendering states in Metal. (as overlay and screen space camera have different depth test rules?)

    To be precise on the bug, text disappeared on overlay canvases, and were visible on world space canvases. When opening a view with screen space camera canvas, text did re-appear on overlay canvases as well.

    In one of the scenes where we did not have Overlay canvases, corruption never happened even when there are mixture of Text Mesh Pro and Text Mesh Pro UGUI objects; that allowed me to trace the cause.

    Nevertheless, the workaround that we only use Screen Space Camera and World Space canvases seems to do the trick for now.
     
    Last edited: Apr 22, 2020
  20. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    4,679
    Are you able to reproduce this behavior reliably? If so could you please submit a bug report with project / repro steps? It would be great if we could get our iOS folks take a look at this.
     
  21. pmerilainen

    pmerilainen

    Joined:
    Dec 23, 2013
    Posts:
    5
    I made a small sandbox project that replicated the language / font changing and I was not able to trigger the text corruption :(
    Therefore the exact cause for the abnormal behaviour remains a mystery
     
  22. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    4,679
    Question, when you say disappear... is the permanently disappear or just for a moment?
     
  23. pmerilainen

    pmerilainen

    Joined:
    Dec 23, 2013
    Posts:
    5
    Fonts that were in Screen Space Overlay canvases disappeared when a scene was loaded, but they did re-appear when a view with Screen Space Camera canvas became visible.
     
  24. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    4,679
    Any chance you can submit a bug report with the project?

    This should not be happening when using <TextMeshProUGUI> objects regardless of having a mixture of them in different space and them sharing the same material preset.

    I would really like to take a closer look to figure out why this is happening.
     
  25. clamum

    clamum

    Joined:
    May 14, 2017
    Posts:
    46
    I was having this issue too; my current points and game timer, both TextMeshProUGUI elements, and a couple little award displays in a dialog box were all not showing up right.

    They were fine in the Editor, but playing on my phone the current points and game timer would disappear after like 30-40 seconds, and the award displays (made up of image and text components) would usually not appear at all when they were supposed to.

    Turned out I did have a TextMeshPro element also in the scene with the TextMeshProUGUI objects and they were using the same material.

    I gave that TextMeshPro a different material than the TextMeshProUGUI elements (went to the gears icon for the material and selected "Create Material Preset" and then switched the material used by the object to that new one).
    See pic below:


    That seems to have fixed the disappearing TextMeshProUGUI objects, but I see at the end of my game one of those little award displays didn't appear when I'm pretty sure it should have. I'll have to do some more testing. Cause the whole award thing didn't display, and it's made up of both an image and TextMeshProUGUI elements, so I don't think it's just a material clash problem.

    Thanks Stephan! I would've never figured out that on my own.
     
    Stephan_B likes this.
unityunity