Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    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:
    5,095
    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?
     
    Xury46, Tudamun, yyylny and 7 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:
    164
    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:
    5,095
    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:
    164
    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:
    5,095
    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:
    164
    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:
    5,095
    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:
    164
    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:
    5,095
    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:
    7
    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:
    5,095
    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:
    7
    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:
    5,095
    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:
    7
    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:
    5,095
    Question, when you say disappear... is the permanently disappear or just for a moment?
     
  23. pmerilainen

    pmerilainen

    Joined:
    Dec 23, 2013
    Posts:
    7
    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:
    5,095
    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:
    51
    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.
  26. lastkatana

    lastkatana

    Joined:
    May 3, 2019
    Posts:
    8
    I have the same problem but I'm not using any TextMesh Pro (to my knowledge at least). My problem is when a certain Canvas is enabled, it's content is not shown (despite all it's Text and Images being enabled and valid) and more interestingly when I STOP the game, the logo and other texts are gone in EDIT MODE!

    I even updated to 2019.4.8 and still persists.

    Reading this topic, I changed material of some of Texts and it seems to have solved the problem but I'm not sure which material should I use and second I don't know why I don't like this "solution", doesn't seem like a "fix" to me.

    Thoughts?
     
  27. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    5,095
    Please be sure to test using the latest release of the TMP package which is:

    Version 1.5.1 for Unity 2018.4
    Version 2.1.1 for Unity 2019.x
    Version 3.0.1 for Unity 2020.x.

    Let me know if the issue persist using the latest release.

    In terms of Material, by default the text objects will use the Default Material included with the font asset. This is the same material available in the Material Preset pull down as seen below.

    upload_2020-8-22_14-43-25.png

    This default material usually corresponds to plain white text (ie material properties unchanged.). I recommend this material never be modified and that additional Material Preset be created which is what these other material preset are in the image above.

    In terms of a potential source of the issue if you are not using normal <TextMeshPro> objects, are you possibly using a mixture of Canvases with different Render Modes like "Screen Space Overlay", "Screen Space Camera" and "World Space"?
     
  28. lastkatana

    lastkatana

    Joined:
    May 3, 2019
    Posts:
    8
    Thanks for the quick reply. I actually did update my TextMesh Pro asset via Package Manager before my post. Re your question, no, both canvases use Screen Space - Overlay.
     
  29. berkhulagu

    berkhulagu

    Joined:
    Sep 6, 2017
    Posts:
    11
    We had that problem for a month or so. In our case, as @Stephan_B wrote earlier, we had <TextMeshPro> and <TextMeshProUGUI> sharing materials. If a TextMeshProUGUI component had a material that is also used by a TextMeshPro, the text on the TextMeshProUGUI component was sometimes not rendered on iOS devices. All TextMeshProUGUI components that did not share a material preset with worked 100% of the time on those devices.

    After using different material presets for each component type, as far as we know, the problem went away.

    Which brings me to my point; maybe we should not be allowed to use the same material preset for both component types. Throwing a compile error ("Error : You are not allowed to use the same material you used in TextMeshPro component in a TextMeshProUGUI component. Hint; create a new material preset for TextMeshProUGUI component and assign that preset to the component") would make things easier.

    I am pretty sure many people are not aware of the issue and never seen this post either.
     
    Last edited: Aug 25, 2020
  30. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    5,095
    That is a good suggestion which I will explore.
     
  31. lastkatana

    lastkatana

    Joined:
    May 3, 2019
    Posts:
    8
    Any thoughts?
     
  32. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    5,095
    Since you mentioned that you are not using any <TextMeshPro> objects and that all text object are <TextMeshProUGUI>, I would suggest using a different set of Material Presets for text objects that are in Screen Space Overlay and another set for those in World Space or Screen Space Camera.

    Again the behavior is related to the ZTest having to be different between Screen Space Overlay objects and World Space and Screen Space Camera objects. Since a material cannot be both at the same time, you get the behavior that you describe.

    The Canvas system / batcher should be handling the above but perhaps there is an issue there but using different sets of materials should resolve the issue. Material on their own are tiny in terms of foot print and since they would still all reference the same atlas texture, there is no duplication of resources and this remains efficient.
     
  33. lastkatana

    lastkatana

    Joined:
    May 3, 2019
    Posts:
    8
    Thanks for the reply but I'm not using TextMeshPro or TextMeshProUGUI. It is default Text components on default Canvases.

    EDIT: This solved it.
     
    Last edited: Aug 29, 2020
  34. yyylny

    yyylny

    Joined:
    Sep 19, 2015
    Posts:
    32
    I can confirm that making sure not to mix materials between TextMeshPro and TextMeshProUGUI fixes the problem. In my case, I didn't notice I was using the default material for both so I just duplicated it and used it on the objects that used to disappear.
     
  35. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    397
    Hi

    In case this helps anyone I was experiencing the same problem whereby TMPro text would not show in game view, and I did not have a combination of UGUI and normal TMPro objects in the scene.

    I think I narrowed this down to a combination of Doozy UI and TMPro where Doozy attempts to scale in a UI View that contains a TMPro component, which would sometimes appear blank - maybe due to the scaling issue?

    My workaround was to remove any scale from the transition and so far it seems to be helping.

    Hope this helps someone.

    N
     
  36. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    5,095
    Do you know what scale Doozy UI would set on the text objects? If their scale ended up at zero then it would certainly explain them not being visible.
     
  37. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    397
    The scale was starting at 0 and ending at 1
     
  38. mhusseini

    mhusseini

    Joined:
    Jul 12, 2019
    Posts:
    4
    How do you load the material? I ran in to a similar situation today. At first, I had the following code (I'm very new to Text Mesh Pro btw):

    Code (CSharp):
    1. target.font = Resources.Load<TMP_FontAsset>($"Fonts/{v}");
    2. target.fontSharedMaterial = Resources.Load<Material>($"Fonts/{v}");
    But after reading this thread I changed it to:

    Code (CSharp):
    1. target.font = Resources.Load<TMP_FontAsset>($"Fonts/{v}");
    2. target.material = Resources.Load<Material>($"Fonts/{v}");
    And voila! the text appeared.
     
  39. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    5,095
    Assigning the font asset to the font property alone would result in the default material being assigned to the text object as well.

    If you are using a specific material preset, then loading it and then assigning it to the fontSharedMaterial property would assign it to the text object where it could be shared by multiple other text objects. Assigning this material preset to via the fontMaterial property, would result in an instance of this material being assigned to the text object.

    In the case of the text disappearing, most likely the material (persistent asset) is being shared between several text objects where some of those could be normal <TextMeshPro> objects or text object using difference Canvas where their Render modes may be different such as some in Screen Space Overlay, Camera Space or World space where the ZTest would be set differently on the same material thus resulting in some of the text disappearing.

    The reason, assigning the material to the fontMaterial appears to resolve the issue is because a new instance of the material is used where the Test is still set but because the material is not shared, it all renders fine.

    If you are trying to use the same material preset on multiple text objects, I would use the fontSharedMaterial property but use different sets material presets (a set for each group of text object using different Render Modes). For instance, if you have some text objects in Screen Space Overlay and some in World Space or normal <TextMeshPro> you would have two sets of material presets. One for each render space.

    The reason for potentially using two or more sets of material presets is to reduce draw calls as each material instance would result in a draw call whereas if you had 10 text objects in screen space overlay and 10 in world space, you would have two material being used by each shared with 10 objects thus resulting in 2 draw calls instead of potentially 20.
     
    mhusseini likes this.
  40. mhusseini

    mhusseini

    Joined:
    Jul 12, 2019
    Posts:
    4
    Thank you for the detailed explanation. The thing is that, as far as I can tell, all my instanced of TextMeshPro are on Screen Space Overlay. On the other hand, I use DoozyUI and there a many canvases involved, so maybe there's another set of conflicts somewhere or I just haven't found the conflicting canvas, yet. For now, I'll go with the extra render calls to get the app finished and hope to fix it at a later point in time.
     
  41. mhusseini

    mhusseini

    Joined:
    Jul 12, 2019
    Posts:
    4
    Oh I forgot: I'm caching the font and the material in a ConcurrentDictionary, so all instances of TextMeshPro get the same instance of the font and material assets. So in effect, isn't the material shared too? Because this setting solved my problem with the disappearing text as well.

    Code (CSharp):
    1. private static TMP_FontAsset LoadFont(string value)
    2. {
    3.     return FontCache.GetOrAdd(value, v => Resources.Load<TMP_FontAsset>($"Fonts/{v}"));
    4. }
     
  42. adipanangat

    adipanangat

    Joined:
    Nov 20, 2020
    Posts:
    1
    Hi guys! I was having this problem as well, and I think I know what causes it. I am creating a game where it gives you your score on one scene and your coin count on you Home Screen, as well as in the skin shop. Firstly, make sure that you do not have a TMpro and TMproUgui with the same material, otherwise, create a new one for one set. Next, check in your script and make sure that you are not actually trying to access a wrong system setting, for me, I was trying to access unityengine.UI. I think these two should fix it.
     
unityunity