- Home /
Huge lag spike when activating a UI.Text GameObject.
Basically I activate (using SetActive(true)) a UI.Text GameObject when the player touches a book. When this happens the first time I get a huge performance hit visible in the profiler: Canvas.SendWillRenderCanvases() (46.4%) : Font.CacheFontForText (8.4%)!
Why? Can I avoid this?
I tried making a script that reactivates the UI.Text GameObject, but this will then cause a:
CanvasUpdateRegistry.PerformUpdate() (77.0%) -> Graphic.Rebuild() -> Text.UpdateGeometry()!
How can the UI be so expensive? This seems horrible. o.o
Basically I'm on Windows 7 with a 3.5GHz processor and 970 GTX and I get horrendous FPS drops due to a SINGLE UI.Text! ...
Answer by SpaceBird_ · Jul 05, 2015 at 09:41 PM
It might be because the canvas your text is on has pixel perfect checked. Pixel perfect can cause performance issues in some cases.
I dont have pixel perfect checked since I'm using World UI scale mode.
Answer by $$anonymous$$ · Jul 05, 2015 at 10:48 PM
Check font settings of the text you use on your UI.Text.
Having insanely high 'Font size' increases the generated font texture and that might yield to what's happening to you. Check the character set as well.
I usually go with Font size : 64 Rendering mode : smooth Character : ASCII default set
The font size was not the problem.
However, I cannot find "Rendering mode: Smooth". Where can I find this?
You can find it when you actually select the font asset (not UI.Text). Try this. Create a new UI.Text it shows that the selected Font (under 'Character' section) is 'Arial'. Change that to your custom font (Drag a font file to unity and select that as the font for UI.Text). If you go to that newly imported font asset, in import settings you would find Rendering mode.
Your answer