Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Bug Scale & Delay triggers regeneration of Textmesh

Discussion in 'UGUI & TextMesh Pro' started by Sandler, Nov 25, 2020.

  1. Sandler

    Sandler

    Joined:
    Nov 6, 2015
    Posts:
    249
    Hi i was just about to optimize my GUI since i was experiencing a few lags on android mobile.
    Most of them were prefab instancing on mobile. (i reposted this, since i put it in the wrong category)

    Anyway im using the latest 2019.4 Version & the latest TMPro package.

    My GUI works like that: After a touch event i scale in (0,0,0 -> 1,1,1) the GUI Window.
    Sometimes there is an delay before i scale in the window.
    The GUIs gameObject is always active and it has a CanvasGroup & Child-Canvas Object on it.

    When i scale in the GUI instantly, without delay i dont get any spikes in the profiler.

    But as soon as i add a frame delay (via delayed update() or StartCoroutine)
    private IEnumerator _WaitForOneFrame(Action callNext)
    {
    // do some actions here
    yield return null; // wait for 1 frames
    callNext();
    }

    I get a spike in the profiler:
    TextMeshProUGUI.InternalUpdate() - 96 calls 1156.64ms
    TextMeshProUGUI.UpdateSDFScale() - 2 calls
    ...GenerateTextMesh() ....

    This Window has two TextMesh Monos, which seem to get regenerated, when i scale it in after a delay. Without delay all works fine.
    I also tested this on Android.

    I will do some more tests, fading it in, or moving it in does not trigger that.
     
  2. Sandler

    Sandler

    Joined:
    Nov 6, 2015
    Posts:
    249
    Update:

    If one side x,y or z is set to 0f this happens. Only if the values are set delayed
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Whenever the scale of a text object or parent changes, in order for the text to render correctly, the SDF Scale which is contains in UV2 needs to be updated. Since there is no callback in Unity related to scale changes, the text objects we check for such potential changes every frame in this InternalUpdate().

    See if you get the same behavior using a very small value for scale. Ie. 0.0001f. Make sure the scale is also uniform / same values for x, y, z.