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?
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.
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.
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.
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.
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.