Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

TextMesh Pro Issue with TextMeshProUGUI.Rebuild()

Discussion in 'UGUI & TextMesh Pro' started by kaladrius-trip, Sep 6, 2019.

  1. kaladrius-trip

    kaladrius-trip

    Joined:
    Jan 14, 2014
    Posts:
    4
    Hello, please help with some issues with unity UI events and TextMeshPro
    I have container with text items without layout groups but in content container in Scroll Rect
    Hierarchy:
    • Canvas
      • Canvas Group
        • Scroll Rect
          • Viewport(with mask)
            • Content
              • TextMeshProUGUI [25-40 objects]
    And when i moving canvas group object just change anchor position, i get this(Deep Profile):

    I think it happens because when i move parent object Unity Event System calls OnRectTransformDimensionsChange() and TMP rebuilds layout. But how to get around this ?

    Unity Version: 2019.2.4f1
    TMP Version: 2.0.1 (from Package Manager)
     
    Last edited: Sep 6, 2019
    ellgood25 and Bladgharm like this.
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    4,275
    This is a long standing issue with the RectTransform that I believe is due to precision / floating point issue where although the size of the RectTransform has not changed, it thinks that it has thus forcing a full update of everything / child of the Canvas.

    This mostly occurs when using Stretch mode on the RectTransform or someone in that hierarchy. It is also susceptible to position values like 1.4331 instead of something like 1.45 where those extra decimal places cause the issue.

    This issue is one of the reasons why in some users report bad performance on the ScrollRect while other don't as it is based on those rounding errors in the calc of the offset position of the RectTransform.

    See if you can re-work how those are setup to avoid these potential rounding errors.
     
    kaladrius-trip likes this.
  3. kaladrius-trip

    kaladrius-trip

    Joined:
    Jan 14, 2014
    Posts:
    4
    Thanks, i found solution and problem in my hierarchy on root canvas has been activated option PixelPerfect and as consequence precision issue on child RectTransform. PixelPerfect isn't perfect.

    P. S. Thanks for TextMeshPro. ;)
     
    Last edited: Sep 6, 2019
    BraveSquire and Stephan_B like this.
  4. petergraham003

    petergraham003

    Joined:
    May 5, 2018
    Posts:
    14
    I am facing this issue and the above solutions didn't work for me. I am using Unity 2019.3.0f6. I have a canvas for one UI screen which I show it in worldspace. It holds around 15 TextMeshProuGUI components and few image components. When the screen is enabled that initial few frames I could see a very big performance hit. It is happening each time I enable that screen. Can anyone provide me a solution to get a seamless gameFlow without any perfomance hit ?
     
    kdeger likes this.
  5. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    4,760
    Do you know if there exists a (internal) bug-report for this issue and it gets fixed eventually? If no ticket exists, do you mind to create one?
     
  6. kdeger

    kdeger

    Joined:
    Mar 4, 2018
    Posts:
    9
    Having the same issue and still looking for a solution, takes 45.5 ms to Rebuild TextMeshProUGUI on OnEnable of a UI popup. Hope there is a simple solution which we haven't noticed yet. Using Unity 2019.3.0
     
  7. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    4,275
    Do your text objects all have auto-size on them?

    Does the hierarchy have layout components?

    How many characters does the text contain?

    All these things can have an impact where OnEnable won't have much impact to a lot more.

    Also be sure to test in a build as there are many events related to Editor stuff that only happen in the Editor but not a build.

    Please always feel free to submit a bug report with the included project for me to take a closer look.
     
  8. kdeger

    kdeger

    Joined:
    Mar 4, 2018
    Posts:
    9
    Disabling autosize fixed the spike for me but we need it for localized texts, is there any option to use autosize without this huge spike?
     
  9. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    4,275
    See the following post which outlines how I recommend using auto-size.

    P.S. I will (once I get a chance / have time) revisit Enabling / Disabling objects to look for potential improvements. I am also working on several other performance improvements but most of them will come from the new TextCore which TMP will use under the hood when it is ready. Ie. improvements will keep coming over time.
     
    segant, mitaywalle and kdeger like this.
unityunity