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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

TextMesh Pro Android BUG? SetText() is not the same as setting .text

Discussion in 'UGUI & TextMesh Pro' started by gforeman, Jan 27, 2020.

  1. gforeman

    gforeman

    Joined:
    May 22, 2019
    Posts:
    2
    The following seems to apply to Android (specifically Oculus Quest) builds and Unity 2019.3.0f5 with TextMesh Pro 2.0.1

    When attempting to set the text of a TextMeshProUGUI component using the SetText() method, visually it looks OK but the value read at some later stage still contains the original value.

    Setting .text works as expected.
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    SetText() goes through a different path and only updates / keeps in sync the .text property in the Editor. This is to avoid allocations.

    SetText() should only be used with short strings and to combine / format the text with variables.

    I also modified the behavior of plain SetText() in 2.1.0-preview.3. By plain SetText() I mean the variant when only using a string. This would should sync at runtime.
     
    gjf and gforeman like this.
  3. gforeman

    gforeman

    Joined:
    May 22, 2019
    Posts:
    2
    Thanks; perhaps some clarification in the documentation could save some future time... not that I saw any reference in here to that method.

    g.