Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug TMP Sprite Error

Discussion in 'UGUI & TextMesh Pro' started by Huminaboz, Apr 21, 2021.

  1. Huminaboz

    Huminaboz

    Joined:
    Mar 12, 2013
    Posts:
    6
    Has anyone seen an issue like this before?

    Placing sprites in text using a typewriting effect causes an error sometimes.

    This is the error:
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. TMPro.TextMeshProUGUI.GenerateTextMesh () (at Library/PackageCache/com.unity.textmeshpro@3.0.4/Scripts/Runtime/TMPro_UGUI_Private.cs:2014)
    3. TMPro.TextMeshProUGUI.OnPreRenderCanvas () (at Library/PackageCache/com.unity.textmeshpro@3.0.4/Scripts/Runtime/TMPro_UGUI_Private.cs:1660)
    4. TMPro.TextMeshProUGUI.ForceMeshUpdate (System.Boolean ignoreActiveState, System.Boolean forceTextReparsing) (at Library/PackageCache/com.unity.textmeshpro@3.0.4/Scripts/Runtime/TextMeshProUGUI.cs:547)
    Example text:
    asdfasdf
    <color=red><b>launch codes</b></color>
    We need to <font=UnicaOneRegular SDF>intercept</font> the <color=red><b>launch codes</b></color> before the enemy launches their weapon at our home world.

    with sprite number <sprite=0>
    with sprite name <sprite name="Smiling face with smiling eyes">

    Sometimes no error pops up but the text gets scrambled.

    Usually, the sprites still show, but the text next to it breaks.

    Deleting and then re-importing TMP files can temporarily fix it, but it soon comes back then continues, as though it were altering the files themselves. In other words, the problem seems to get worse after repeatedly trying the same thing.

    If I remove the sprites from the text completely, everything works as intended.

    I've submitted a bug report, but they've only suggested the re-import fix.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    If you can post the Case # of this report, I can take a closer look as soon as I have a chance.

    P.S. What version of the TMP package and Unity are you using?
     
  3. Huminaboz

    Huminaboz

    Joined:
    Mar 12, 2013
    Posts:
    6
    (Case 1326754)

    Unity Version: 2020.3.0f1
    TMP... how do I check? I just reimported it yesterday, so I assume the latest version.
    The user guide says Release 1.0.54
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    You would check via the Package Manager located in the Window menu.

    upload_2021-4-21_0-56-43.png
     
  5. Huminaboz

    Huminaboz

    Joined:
    Mar 12, 2013
    Posts:
    6
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I'll try looking at that case later tonight / over the new few days if I can't get to it tonight.