Search Unity

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

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

  1. adbourdages

    adbourdages

    Joined:
    Jul 8, 2012
    Posts:
    43
    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:
    2,801
    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:
    43
    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:
    2,801
    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
  5. TheBladeRPG

    TheBladeRPG

    Joined:
    Aug 17, 2014
    Posts:
    23
    Hello,
    I have exactly the same issue, purple blocks instead of the text.
    I had to move all my projects to a different disk location, since i've done that, no more text, it's a disaster...
    I thought that everything related to a project is supposed to be inside the project folder, isn't it the case ?
    Whatever is the problem, how to fix it please ?
    im using Unity 2017.1.1f1

    also, but this is less important, the problem occurs if i try migrate a project to a recent unity version, all text go purple blocks.
     
    Last edited: Nov 27, 2018
  6. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    2,801
    Purple blocks indicates missing shaders or materials. I would suggest creating an empty project at the new project / file location and then importing TextMesh Pro to see if you get the same behavior. Let me know if everything works as expected with the new project.

    In terms of migrating to a new version of Unity, for Unity 2018 and up, you will need to get the new version via the package manager. The migration / upgrade process is covered in the following post. Be sure to review the updated notes at the bottom of the first post.
     
  7. TheBladeRPG

    TheBladeRPG

    Joined:
    Aug 17, 2014
    Posts:
    23
    Hello Stephan_B, thank you for the feedback.

    Creating new projects with TextMesh works well. Moving the projects to another location works well too, runing them from a different user session works well too. (im testing with Unity 2017.1.1f1)

    So this problem of purple blocks is only happening to my old project.

    In my case i just noticed that unity was throwing the following errors in different cases :

    case 1 - restored project to it original location, but open it from a different session user
    could not access c:\ProgramData\Unity\Unity_lic.??? (sorry im writing this from my memory i forgot the exact terms)

    case 2 - copied the whole project folder to another disk and open it from a different session user
    Shader error in 'TextMeshPro/Distance Field': failed to open source file: 'TMPro_Properties.cginc' at line 126 (on d3d11)
    Compiling Vertex program
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA UNITY_LIGHT_PROBE_PROXY_VOLUME

    I totaly ignore why is trying to access ProgramData regarding to the project, i never did any setting in this way.

    So i decided to test something, i run unity as administrator

    case 1 - restored project to it original location, but open it from a different session user
    this fixed the TextMesh problem, text is back in the correct color, but now there are shader issues on the whole scenes in the editor, when open scene it look good for 2 seconds and then it look like it has been "iced" or "frozen with cold"

    case 2 - copied the whole project folder to another disk and open it from a different session user
    Shader error in 'TextMeshPro/Distance Field': failed to open source file: 'TMPro_Properties.cginc' at line 126 (on d3d11)
    Compiling Vertex program
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA UNITY_LIGHT_PROBE_PROXY_VOLUME
    (so case 2 remain unchanged, project is broken)

    - so now im very worried because this means i cannot move my projects for the moment
    - why do i need to run as administrator ?
    - why is there are data in c:\ProgramData regarding to the projects?

    how to fix this mess ?
    thank you for helping

    Edit:
    I tried to re-import TextMesh Pro, very bad idea, it broke the project, all texts have vanished, all references to text object and scripts are broken, there are around 300 references to fix, so i wont do that.
    I hope that there is a different solution
     
    Last edited: Nov 27, 2018
  8. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    2,801
    What version of TextMesh Pro are you using?

    Are you using the free / DLL only version from the Asset Store or the original source code version purchased from that Asset Store?

    When re-importing TextMesh Pro, you have to make sure you stick to the same version in terms of the DLL-only or the source code version. You cannot go back and forth between those.
     
  9. sunwangshu

    sunwangshu

    Joined:
    Mar 2, 2017
    Posts:
    4
    I have seen a similar issue, and the way I fixed it was by checking the "TexCoord1" on Canvas -> "Additional Render Channels".

    Hope it helps : )
     

    Attached Files:

  10. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    7
    I had the same problem. After reading this thread i discovered, that the z-Value of the RectTransform Scale-Value was 0.