Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    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.