Search Unity

TMP 1.5.3 Causing Clipped Text Rendering

Discussion in 'UGUI & TextMesh Pro' started by f0ff886f, Nov 26, 2020.

  1. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    201
    This repros directly after updating to TMP 1.5.3 (no other changes). Previous version was 1.4.1, Unity 2018.4.16f1.

    I don't know what to call this, apologies if clipping is incorrect.

    Here is a video that shows the problem:



    Some settings (the transform fits):
    upload_2020-11-26_22-30-38.png

    upload_2020-11-26_22-31-20.png

    Is there any idea what could be set wrong? Or is this just a bug? I can try to create a small repro in a separate scene, if it is not obvious.

    Thanks!
    Matt
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    This could be caused by a change to reduce memory overhead of text objects where some of the internal processing data structures are static and shared by objects now.

    How are you handling the update of those two objects in terms of the color change?
     
  3. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    201
    We change faceColor for the color, and fontStyle like so:

    Code (CSharp):
    1. // for the colour:
    2. TMP.faceColor = BlueHighlight;
    3.  
    4. // for the font style:
    5. TMP.fontStyle = FontStyles.Underline | FontStyles.SmallCaps;
    I believe this creates a material instance? Would it be better to affect the Vertex Color instead?
     
  4. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    201
    Trying to use just
    Code (csharp):
    1. TMP.color
    didn't change the behaviour. It only happens when the word is underlined, if I deselect it and toggle the colours by hovering mouse on/off, I can never repro the cut off rendering.

    Moreover, if I toggle the underline in the UI (while it is in the cut-off state), the word fully reappears and will not repro (until I programmatically remove the underline and re-add it by changing the actual options).
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Can you please submit a bug report with repo project?

    This should be an easy fix once I am able to reproduce it with that project.

    Once you get the Case # from Unity via email, please post it here.
     
  6. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    201
    I will work on creating the repro project for you and come back with the Case # as soon as I have it.
     
    Stephan_B likes this.
  7. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    201
    Last edited: Dec 1, 2020
  8. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Please give the following change a try and let me know if that resolves the issue.

    In the TMPro_UGUI_Private.cs in the OnPreRenderCanvas() function around line 1616, make the following change which will force the text input to always be parsed when any of the text properties are changed.

    Code (csharp):
    1.  
    2. // Reparse the text if the input has changed or text was truncated.
    3. if (true) // m_isInputParsingRequired || m_isTextTruncated)
    4. {
    5.     #if TMP_PROFILE_ON
    6.     Profiler.BeginSample("TMP - ParseInputText()");
    7.     #endif
    8.  
    This is a temporary change while I review / consider if we should always re-parse which potentially adds performance overhead when a text property is changed which in theory would not require re-parsing of the text. For instance, changing the vertex color does not require re-parsing. The trade-off is lower memory overhead as some of the internal data structures can be shared between all text objects.
     
  9. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    201
    Hi Stephan!

    I tried it out but it didn't work... however, our display labels are not rendering with UGUI for the menus, they're just regular TMPro objects. So I edited TMPro_Private.cs line 1530 and short-circuited the conditional as you provided... and it works!!!

    Thank you so so so so so much!

    I don't think we are too concerned with memory usage in our game at the moment, so we will apply this fix.

    A question though, how can I version this change to the TextMeshPro package? Should I copy away the package directory, uninstall the package, and then pull in the package contents to my project directly?

    Matt
     
  10. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    First, this fix will be included in the next package release.

    Until then, you can embed the package in your project by taking it from the Global Package Cache and copying it in the Packages folder in your project. When embedding a package it is import to know that it will prevent you from installing newer versions of the package until the embedded version is removed.

    Alternatively, you could simply make those changes in the package in the Global Package Cache for that specific version of the package which for example would be "...\AppData\Local\Unity\cache\packages\packages.unity.com\com.unity.textmeshpro@1.5.3" on windows.

    Modifying the files in the global package cache might be easier in terms of future updates and if it is to only address this fix vs. if you want to source control your own modifications to TMP where embedding the package would be a better solution.
     
  11. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    201
    Thank you Stephan. I will embed for now, as this project is post-release and we're just trying to get localization working for CJK languages. Unless the next package release is coming in the next couple of weeks, I'll embed :) That way I won't lose the fix on the laptop vs. the desktop, it'll get carried with the project.

    Thanks for the instructions, the fix. I hope you have a happy holidays!