Search Unity

TextMesh Pro Crash/Editor freeze with TextOverflowModes.Ellipsis + multiline + subscript

Discussion in 'UGUI & TextMesh Pro' started by evilock, Mar 23, 2020.

  1. evilock

    evilock

    Joined:
    Sep 19, 2016
    Posts:
    20
    I'm on 2.1.0-preview.8. Steps to reproduce:

    - Create a TextMeshProUGUI element in an empty scene
    - In Inspector, set height to 100 (or enable Auto Size) to fit more than one line
    - In Inspector, set overflow to Ellipsis
    - In Inspector, begin text with <sub> and start typing until a new line wouldn't fit anymore and text should be truncated with ellipsis shown.

    I wonder what's going on here and would there be a workaround?
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I was able to reproduce the behavior with the steps you provided.

    This issue is an edge case related to using superscript on the first character. I'll try taking a look at this later today and provide some feedback once I have more information.

    Out of curiosity, what is the use case for using superscript on the first character of the text?
     
    Last edited: Mar 23, 2020
  3. evilock

    evilock

    Joined:
    Sep 19, 2016
    Posts:
    20
    The use case is allowing user input with rich text. Some seem to love their subscript...
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Users exploiting o_O

    I'll follow up as soon as I have more information, I should be able to get this resolve in Preview 9.
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The following changes in both TMPro_Private.cs around line 3090 and TMPro_UGUI_Private.cs around line 3188 should resolve this issue. This change will need to be made in the Global Package cache.

    Code (csharp):
    1.  
    2. // Replace this single line
    3. float textHeight = m_maxAscender - m_ElementDescender + (m_lineOffset > 0 && m_IsDrivenLineSpacing == false ? m_maxLineAscender - m_startOfLineAscender : 0);
    4.  
    5. // With the following
    6. float ascender = Mathf.Max(elementAscender, m_maxAscender);
    7. float textHeight = ascender - m_ElementDescender + (m_lineOffset > 0 && m_IsDrivenLineSpacing == false ? m_maxLineAscender - m_startOfLineAscender : 0);
    8.  
    Please confirm this change is working as expected on your end.

    This change will be included in Preview 9 of the TMP package which I will try to release over the weekend.
     
  6. evilock

    evilock

    Joined:
    Sep 19, 2016
    Posts:
    20
    Unfortunately that doesn't help, I'm still getting the same even after making those changes.
     
  7. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Make sure the change is made in the Global Cache otherwise the changes are lost whenever you close / open Unity.

    I will re-check again on my end.
     
  8. evilock

    evilock

    Joined:
    Sep 19, 2016
    Posts:
    20
    Hi Stephan, any update on this? I can still reproduce this using the same steps. Unity 2019.2.21f.

    I added some log output to make sure the altered versions of the classes are in use, even tried replacing the other similar lines of code (around 2444 in TMPro_Private.cs and 2542 in TMPro_UGUI_Private.cs).
     
  9. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I am still working on Preview 9 and working on making sure these issues are resolved. There are some edge cases that I was not covering well like the use of superscript (the entire text) or <voffset> or crazy mix of the above.