Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  4. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

TextMesh Pro What causes text to be rendered as blocks instead of letters

Discussion in 'Unity UI & TextMesh Pro' started by adbourdages, Sep 13, 2018.

  1. adbourdages

    adbourdages

    Joined:
    Jul 8, 2012
    Posts:
    34
    Hello,

    I have been using TMPro for year and from to time the game will start but all the text is shown with blocks instead of letters. Next game start, no problem it runs fine.

    What is causing it and how can I mitigate it?

    - The problem is happening from Unity 5.4 to 2018 - and a range of version of TMPro over the years.
    - I've attached an image of what it looks like (no from my game, but it looks exactly like that). The blocks look like they are the size of the letters.
    - It works 99.9% of game launches but sometimes: white blocks (all on the same device without reinstallation of the game)
    - This is using the Distance Field 16 algo
    - It happens on Android (and chromebooks). I haven't seen that problem on PC/iOS (but that might be due to number of players on each platforms)
    - I'm guessing the blocks are colored white because it is my text color scheme. Probably not relevant.
    - I'm not fudging around with the created font assets
    - But there are some sprite assets in the project

    I'm happy to provide more details as needed but I feel like this is not a new issue. I just can't find guidance on what to do about it.
     

    Attached Files:

  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,634
    There are a few things that can result in this.

    The first is Unity somehow losing reference to the texture of the font atlas. This is an internal Unity issue and not related to TMP. From TMP's perspective, the texture is still valid but it happens to be some empty texture. This can be timing related as resources are being loaded.

    The second is potentially related to non-uniform scaling of the text object or the Scale X and Y located in the debug section of the material inspector being set to a value of 0.

    This is also possible when using texture compression (which should be avoided with font atlas texture).

    The biggest challenge here is being able to reproduce the issue to isolate the cause.
     
  3. adbourdages

    adbourdages

    Joined:
    Jul 8, 2012
    Posts:
    34
    Since this problem can happen with the same executable, it kind of rules out the non-uniform scaling and texture compression.

    The code in the game doesn't ever touch the font reference to the atlas so that leaves Unity losing the reference during load time. But I've never really seen that happen to anything other than TMPro. Most other missing references in the scenes would cause pretty serious crashes or at least a few NullException.

    There has been no luck so far getting logs from a player that exhibited the problem however.
     
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,634
    It does look like some loading / timing issue. This loss of reference to the texture (texture ID to be more specific) occurs on the native side and from the managed side, you still have a valid texture. It is simply and temporarily pointing to the wrong texture.

    This behavior has been around for a while and in the past could occur during assembly reload or when switching build platform.

    Most of these issues got fixed over time but I think the underlying root cause remains somewhere as this keep resurfacing in some form or fashion. For instance, changing texture settings like quality can trigger this behavior in Unity 2018.2 and 2018.3. This is being investigated.

    The biggest challenge is getting repro projects to allow us to reliably reproduce the behavior.
     
    Last edited: Sep 14, 2018