Search Unity

Question Issue with unsupported text

Discussion in 'UGUI & TextMesh Pro' started by UserNobody, Jan 11, 2021.

  1. UserNobody

    UserNobody

    Joined:
    Oct 3, 2019
    Posts:
    144
    Hello there,
    Is there a way to check if the added text to the TextMeshProUGUI object contains any missing/unsupported characters or if any other potential fallback occurred?

    I have this in-game console, where all kind of text is being added to it. After a certain text was added the TextMeshProUGUI object would not change at all whenever a new text was appended to it. And when I tried to edit a text in the inspector, I received this warning message:

    The character with Unicode value \uFFFFFFFF was not found in the [clacon SDF] font asset or any potential fallbacks. It was replaced by Unicode character \u25A1 in text object [coText].

    The only solution to make the text update again is to delete all the current text. Are there any ways in handling such fallbacks? Thank you
     
  2. UserNobody

    UserNobody

    Joined:
    Oct 3, 2019
    Posts:
    144
    I found sort of a solution, which is doing something like that:

    Code (CSharp):
    1. conText.font.HasCharacters(input, out List<char> missing);
    2.  
    3.             if (missing != null && missing.Count > 0)
    4.             {
    5.                 for (int i = 0; i < missing.Count; i++)
    6.                 {
    7.                     input = input.Replace(missing[i].ToString(), "X");
    8.                 }
    9.             }
    The problem I get is when I do that for some reason after the text is appended I receive an error message:
    Code (csharp):
    1. IndexOutOfRangeException: Index was outside the bounds of the array.
    2. TMPro.TMP_Text.DrawTextHighlight (UnityEngine.Vector3 start, UnityEngine.Vector3 end, System.Int32& index, UnityEngine.Color32 highlightColor) (at Library/PackageCache/com.unity.textmeshpro@3.0.1/Scripts/Runtime/TMP_Text.cs:7073)
    3. TMPro.TextMeshProUGUI.GenerateTextMesh () (at Library/PackageCache/com.unity.textmeshpro@3.0.1/Scripts/Runtime/TMPro_UGUI_Private.cs:4305)
    4. TMPro.TextMeshProUGUI.OnPreRenderCanvas () (at Library/PackageCache/com.unity.textmeshpro@3.0.1/Scripts/Runtime/TMPro_UGUI_Private.cs:1647)
    5. TMPro.TextMeshProUGUI.Rebuild (UnityEngine.UI.CanvasUpdate update) (at Library/PackageCache/com.unity.textmeshpro@3.0.1/Scripts/Runtime/TextMeshProUGUI.cs:224)
    6. UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at C:/Program Files/Unity/Hub/Editor/2020.2.1f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/CanvasUpdateRegistry.cs:217)
    7. UnityEngine.Canvas:SendWillRenderCanvases()
    8.  
    It is pointing to a TMP_Text.cs class.

    If I instead replace the missing characters with an empty string, the error does not occur.

    Is this a bug?
     
  3. UserNobody

    UserNobody

    Joined:
    Oct 3, 2019
    Posts:
    144
    Actually nevermind, apparently the "solution" I showed above is not working at all... It replaced the characters, but I still get same fallback warning. :/
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    These warnings can be suppressed in the TMP Settings as seen below.

    upload_2021-1-11_16-13-33.png

    The HasCharacters function and variants can be used to determine if the font asset contains specific characters. You can also control if it should check the fallbacks as well.

    Missing characters are automatically replaced by the missing glyph symbol Unicode code point = 0 or whatever other character you might have specified in the TMP Settings in the Missing Character Unicode field seen above.

    In terms of the text not updating, that seems to be some other issue. This input text in your console, is that fixed size or does it eventually grow to some large size?
     
    Gravesend, Kujji, DhiaSendi and 2 others like this.
  5. wechat_os_Qy05cgG05hr358Y26WAk8mECo

    wechat_os_Qy05cgG05hr358Y26WAk8mECo

    Joined:
    Jan 19, 2022
    Posts:
    2
    I also meet this problem. At present, my only solution is to re create the asset, and then manually replace all the assets, which was being used.Update Atlas Texture seems to be useless
     
    Magic-Thor likes this.
  6. wechat_os_Qy05cgG05hr358Y26WAk8mECo

    wechat_os_Qy05cgG05hr358Y26WAk8mECo

    Joined:
    Jan 19, 2022
    Posts:
    2
    Well,another reply has helped me, just ticked Multi-Atlas Textures when Update Atlas Texture. I have no idea but it works
     
    ilmario, DhiaSendi, eastlaugh and 4 others like this.
  7. eastlaugh

    eastlaugh

    Joined:
    Jul 8, 2021
    Posts:
    1
    I love you.It works
     
  8. FranklinLisboa

    FranklinLisboa

    Joined:
    Mar 10, 2017
    Posts:
    5
    where is this option?