Search Unity

Resolved Textmesh Pro suddenly black boxes instead of characters?

Discussion in 'UGUI & TextMesh Pro' started by Gordon_G, Mar 20, 2022.

  1. Gordon_G

    Gordon_G

    Joined:
    Jun 4, 2013
    Posts:
    372
    Hey, I tried to add a TMP text field to a canvas inside a prefab, and instantly all of the TMP text fields in the whole project are displaying only black boxes!





    Any idea how to fix this and what would have cause it?
     
    TheOlumide likes this.
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    What do you mean by adding to a Canvas? Do you mean as a child of a Canvas that is part of a prefab?

    Can you provide more information on that prefab? Images of the prefab setup / children / etc.

    When you inspect existing text objects in the project that are not part of this prefab, do they still have a font asset assigned to them? The material used by these text objects, when you look at the debug section of the material inspector, does the material still have an atlas texture assigned to it?
     
  3. Gordon_G

    Gordon_G

    Joined:
    Jun 4, 2013
    Posts:
    372
    Hey thanks for your reply!

    Yes, I created a prefab previous to this. I had the prefab open to edit. I added a canvas to the prefab and then I added a Textmesh Pro object text field to that canvas and saw that the characters we all blocks. When I exited editing the prefab, I saw that all the other Textmesh Pro text fields in my project now looked the same.

    Here is the hierarchy of the prefab:
    upload_2022-3-20_16-32-46.png

    For the materials, I'm not sure where I should look - in debug on the inspector for the TMP fields I don't see anything different than the previous version of the project where everything is working. Can you be more specific about where I need to look?

    I mean it is possible I did something, because the canvas I added uses World space rendering mode, and initially the scale was huge. So I don't know if I did something in the TMP pro field inspector while I was trying to reduce the scale of the whole canvas and text.

    This is in a branch of my main repo, so I don't want to merge back until I get this fixed!
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Are all other text objects using this same prefab?

    With respect to the debug section of the material inspector of the text object, the image below is what I mean.

    upload_2022-3-20_23-6-9.png

    In the Font Atlas slot, do you appear to have a material there?

    Can you post a picture of the material inspector of one of your text objects that is rendering as grey boxes?
     
    tom41_10tt, TheOlumide and Le_Jo like this.
  5. Gordon_G

    Gordon_G

    Joined:
    Jun 4, 2013
    Posts:
    372
    Yes, the atlas was missing. I connected it with the correct asset and that fixed it for every field.

    Thank you so much, Stephan! I did a lot of searching on the web and didn't find much of anything about others who have had this problem.

    Not sure how the material went missing because I am 100% sure I didn't touch that at all. I'm working on a new Mac silicon system running Unity 2020.3.11f1 under Rosetta so who knows! (not ready to move to 2021 and the Unity native Silicon editor yet).

    Thanks again & all the best,
    Gordon
     
    Le_Jo likes this.
  6. PelusoWarro

    PelusoWarro

    Joined:
    May 12, 2016
    Posts:
    8
    I am experiencing this issue randomly since yesterday. I went through all hierarchy to make sure my texts are not raycast targets. Then, just because... Some texts decided to be a black square.. does not make sense.

    If i click the "debug settings ( making sure it actually have a font atlas ) all becomes good and the texts are visible again.
    This is very weird. Today, another couple texts become black squares, Those texts are not linked to any class or being modified in runtime. Fixed the issue deleting those text and creating new ones.

    The solition of re-creating seems to work. but it gives me a lot of insecurity, knowing at any moment, any text could become a black square?
    Thanks
     
    Gordon_G likes this.
  7. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,086
    I understand that insecure feeling... lots of corners of Unity give me those feels.

    This, with TextMesh Pro, shouldn't happen too often... if it does, again, ping me and I'll take a look. There's more than one reason why it might drop out like this, and most of them are to do with various "updates" and the kind of thing you've done, wherein you're optimising things and/or generally housekeeping and cleaning up.

    So far, touch wood, I've never experienced an irrecoverable situation with TextMesh Pro corruptions, and I've pushed it a bit. I can't say the same for things like Scenes and Prefabs, with which I've had all sorts of irrecoverable losses. TextMesh Pro hasn't ever gone that funky, on me.

    Like Cinemachine and the Legacy Animation System, I think TextMesh Pro is one of the more stable (and fun) parts of Unity.
     
    Gordon_G and Stephan_B like this.
  8. Josh_He

    Josh_He

    Joined:
    Nov 19, 2013
    Posts:
    14
    Hi, I had the same issue, at least the same symptoms!

    In my case, it was due to the Text being a child of an object that gets scaled to 0 on start. This seems to result in a wrong level of detail getting picked, which is not updated after I scale the parent back up (with a "pop-up" animation). I tested to set the scale to 0.05 in the beginning and the result was a very low level of detail, but you could still make out the letters.

    The actual fix in my case was to delay setting the scale to zero by one frame (using a coroutine). I think the Text initializes itself while it's still scale 1 this way and therefore works normally afterwards.

    Hope it helps!
     
  9. IgorAherne

    IgorAherne

    Joined:
    May 15, 2013
    Posts:
    393
    I had this because camera-space Canvas was too close to its camera, like 0.1
    Moving it back (Canvas->Plane Distance) to something like 0.13 fixed it