Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug textMeshPro.textInfo.linkInfo still contains previous links after changing text content

Discussion in 'UGUI & TextMesh Pro' started by raceking37, Feb 9, 2023.

  1. raceking37


    Jun 9, 2020
    I'm working on a script that uses the <link> tag for creating custom "tags". While working on this I noticed that when the contents of the text box changes (textMeshPro.text), the contents of "textMeshPro.textInfo.linkInfo" doesn't get cleared. This can cause some unexpected behavior, in my case:

    - I have some text which contains parts that I'd like to animate using for example <link="wave"></link>. In my code I go through the links stored inside textMeshPro.textInfo.linkInfo and handle them accordingly (in my case, animate the <link="wave"></link> enclosed characters with a wave effect). However, problems arise when the text is changed to something that has no or fewer links than the previous text since this means that in this case some of the previous links are still present inside textMeshPro.textInfo.linkInfo. In my case, this meant that previous tags were affecting the new text.

    For me, it's possible to fix this in code (example: by using the linkCount to not go beyond the number of links that are in the current text) but I feel like this might be unwanted behavior in TextMeshPro? Or is it supposed to be this way.
  2. sp-LeventeLajtai


    Jul 11, 2019
    I suspect that you might need to manually force a rebuild of the
    structures, but I couldn't find anything clearly stating that it does that in the documentation. Maybe
    could do it?