Search Unity

Canvas UI Text - Not Updating (Unity 2019.1.0f2)

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by Plumpman, Apr 18, 2019.

  1. Plumpman

    Plumpman

    Joined:
    Sep 7, 2012
    Posts:
    19
    I'm getting a major issue with Canvas UI Text in Unity 2019.1.0f2.
    All my text fields are no longer updating reliably when setting them through code.

    My text is properly being set, and I can see it in the text's inspector, but its not reflected in the editor or game view because the canvas doesn't want to refresh itself. It thinks nothing has changed and so doesn't update the text fields. If I go to my Canvas and change the Canvas Scaler Reference Resolution around, it then forces an update and all my text is updated in editor and game view.

    EDIT: Changing the Main Canvas (root) object's hierarchy also triggers a refresh.
     
    Last edited: Apr 18, 2019
  2. Tomer-Barkan

    Tomer-Barkan

    Joined:
    Jul 31, 2012
    Posts:
    118
    I've had this happen in 2019.1.2f1 too. Not text, changed color of an Image and the color didn't change. Later even tried disabling and entire UI GameObject and it just stayed there, not disappearing at all.
     
  3. N_Murray

    N_Murray

    Joined:
    Apr 1, 2015
    Posts:
    98
    I've had this problem a few times and moving the UI code to late update instead of update usually fixes it for me. I hope it helps
     
  4. roka

    roka

    Joined:
    Sep 12, 2010
    Posts:
    454
  5. sampenguin

    sampenguin

    Joined:
    Feb 1, 2011
    Posts:
    18
    I just ran into this issue with a Text component .text not rendering correctly in 2018.3.1f1 via code change, but behaving correctly if I manually edited the text value in inspector.

    In my case, it seems to be because the chain of code was flowing from a System.Timer Elapsed event call (text being updated every X milliseconds due to this event). For whatever reason, if the ultimate .text = "whatever" code executes from that approach, I can see it update in Inspector window, but the renderer (both scene and game view) do not update. Even tried called SetAllDirty() and Rebuild(), didn't change behavior. Never seen this kind of thing before.

    However, I refactored to use Unity's Update() method and a lightweight timer approach with Time.deltaTime (eliminating the use of a System.Timer), and now it works as expected (scene and game view both update rendering to what is in the .text value field in Inspector). Go figure.