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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

UI Text Performance

Discussion in 'UGUI & TextMesh Pro' started by ToshoDaimos, Aug 27, 2016.

  1. ToshoDaimos

    ToshoDaimos

    Joined:
    Jan 30, 2013
    Posts:
    679
    I made development console using new UI. When it scrolls I repopulate a bunch of UI Text objects with new strings. Each text change takes 2ms! Changing 50 strings in a frame takes 100ms! This performance is horrible. Is there some workaround or is it a bug? Wait, maybe it's a feature... -_-

    Is changing UI text strings always so slow or maybe I'm doing something wrong?
     
  2. IzzySoft

    IzzySoft

    Joined:
    Feb 11, 2013
    Posts:
    376
    Are you animating each character... Typewriter effect, adding a character ever frame maybe?
     
  3. ToshoDaimos

    ToshoDaimos

    Joined:
    Jan 30, 2013
    Posts:
    679
    I just set different text. I also manually apply transforms and set deltaSize. I set deltaSize to Vector2.zero to avoid using SetActive(false) for hiding game objects. Deep profile shows that there are many Graphics.Rebuild operations and each of them takes around 2ms. I use dynamic fonts. Pixel perfect is off for canvas.
     
  4. ToshoDaimos

    ToshoDaimos

    Joined:
    Jan 30, 2013
    Posts:
    679
    Damn, It seems I will AGAIN have to go C++ DYI style. I will make my own gui with procedural meshes. What a mess...
     
  5. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    421
    Just want to share something here. I've run a test on Text UI few weeks ago. If you call 'SetAllDirty()' on every frame on a text which has 3500 characters, then my FPS would drop from 60 to 30 FPS (this results ~30 ms on each update, with default text settings). If yor text has at least one UI effect (shadow, etc.) then FPS will drop badly (GC allocation problem).

    I still don't know exact solution but at least turning off rich text, best fit, and using non-dynamic font would likely make the text rebuilds faster.
     
  6. IzzySoft

    IzzySoft

    Joined:
    Feb 11, 2013
    Posts:
    376
    Did you look at TextMesh Pro yet? You might not need to recreate it. ;)
     
  7. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Just for testing purposes would you mind sharing (privately with me if desired) the scene / setup that is giving trouble? I would love to take a look and see how TextMesh Pro would perform on this and what potential optimizations, I could suggest.
     
    Last edited: Aug 27, 2016
  8. ToshoDaimos

    ToshoDaimos

    Joined:
    Jan 30, 2013
    Posts:
    679
    That console is built on top of my Panel System which has custom widgets made using Unity stuff. I will most likely rebuild that system to avoid using Unity UI altogether. I would love to use Text Mesh Pro for my text widget but I also need a robust way of text input. I need full paragraph editing which is possible using UI Text with Input Field. Does TMP support this kind of editing yet? I looked online and couldn't find almost anything about text input. I could use TMP for text output but I still need to implement good input: with highlighting, ctrl+c/v, tabs, arrow keys, insert/delete, etc.
     
  9. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    The TMP Input Field replaces Unity's UI Input Field and mirrors its functionality, including the features you listed above. It also features a few extra things as seen below.



    I would still love to see and test your existing setup to see how replacing Unity's UI Text by the TMP UI Component along with making some optimizations which are usually made possible by using TMP would provide.