Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

TextMesh Pro (Case 1122419) Text not displayed until changing Component

Discussion in 'UGUI & TextMesh Pro' started by Peter77, Jan 30, 2019.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,640
    The text of a "Text Mesh Pro UGUI" is not displayed, until the Component gets disabled/enabled or any of its properties are changed. Please see the video below.

    The problem for me is that all texts in all menus are gone. It seems I have to toggle each Text Component in every menu, which is near one gazillion. Is there a workaround for this issue?


    Reproduce
    1. Open user attached project from Case 1122419
    2. Open Assets/menu.unity scene
    3. Expand in Hierarchy menu_pause > canvas > screens > main > buttons > resume button > button_main
    4. Select "Text" GameObject
    5. Notice its text is not displayed in the scene and game view
    6. Toggle the "Text Mesh Pro UGUI" Component
    7. Observe the text is now displayed

    Actual
    The TextMeshPro UGUI text is not displayed. The text is also not displayed when entering play mode.

    Expected
    The text should be displayed.

    Note
    Using TextMeshPro 1.3.0 package, which is 2018.3 verified.
     
    Last edited: Jan 30, 2019
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    I'll take a look this afternoon and provide feedback once I have more information.
     
    Peter77 likes this.
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    The reason for the behavior is due to the fact the text "Input Source" is set to "Set Char Array" as seen in the image below when inspecting the text object with the Inspector in Debug mode.

    upload_2019-1-30_17-52-7.png

    Now the Input Source mode is set internally based on the source of the input. For instance, if the text is set via the Inspector or string, then the mode is Text or String. If the text is set via SetText() then it is set to SetText. Lastly if the text is set using the .SetCharArray mode then the input is set to that mode.

    So to resolve the issue, simply change this value to Text via the Inspector in Debug Mode.

    Now the more challenging / puzzling question is how did the Input Source mode get into that mode in the first place. Are / were you at some point setting the text via this SetCharArray() function?

    P.S. Thank you for having taken the time to submit the bug report with project as it made it quick / easy to find the cause. Without the Repro project, I would have been guessing for a while.
     
    Last edited: Jan 31, 2019
    Peter77 likes this.
  4. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,640
    OK, thanks for the quick help!

    I never used SetCharArray, so that can't be it. I guess it's more likely that something went wrong during the upgrade process.

    The project was using 2018.2 and the TMP package from the AssetStore. I then upgraded to 2018.3 and the TMP PackageManager version.
    1. Upgraded the project to 2018.3
    2. Removed the TMP asset store package
    3. Added the TMP package from PackageManager
    4. Ran your conversion tool
    After these steps, 90% of the texts were gone.

    Looking at the "Input Source" field though the Inspector, interestingly, some are set to "Text" while others are set to "SetCharArray".
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Most likely all of those with SetCharArray will exhibit the same issue so I would switch all of them to Text.

    The challenge here is figuring out how they ended up this way but most likely not worth investing time into it since manually changing them to Text will solve the issue. Now if the behavior returns then it would be worth trying to isolate what steps might actually lead to this.

    Interestingly enough this is the first occurrence of this behavior and fortunately for other users, this thread will provide some insight as to how to resolve potential text not rendering in the editor.
     
  6. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,640
    Is there any case when it should not be set to "Text"?

    I'm asking, because we have some automatic data validation tests and I could add a test that this "Input Source" setting must be "Text" always. This would allow us to automagically catch if it changes again in our project.

    But the test would only work if TMP never assigns something else than Text on purpose.
     
  7. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Yes.
    If the text is set via the .text property then it will reflect "String".
    If it is set via the Inspector then "Text".
    If via SetText() then "SetText"
    lastly if set via SetCharArray() to "SetCharArray".
     
  8. shashkes

    shashkes

    Joined:
    Mar 16, 2017
    Posts:
    19
    I'm having the same issue but the set input source is grayed out and I can't change it. Strangly enough the input source is getting set to char array only when i play the scene before that it is set to text. Even stranger this is the exact game object that works perfectly in another scene in the same project. any suggestions? upload_2020-2-27_17-20-40.png
     
  9. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,640
    I changed it in the .prefab / .unity scene files directly using just a text editor. Requires "Asset Serialization Mode = Force Text" (link).