Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: guillopuyol on February 17, 2015, 06:22:24 PM

Title: Font.CacheFontForText Causes Lag - NGUI Fonts
Post by: guillopuyol on February 17, 2015, 06:22:24 PM
Hello, I have all my labels using NGUI Fonts (not dynamic) yet I'm seeing a huge lag on the first time my label get updated.  In profiler I'm seeing Font.CacheFontForText to be the culprit.

Since I'm not using anything but NGUI Font, I'd like to know what could be causing the font texture to be re-written causing this lag.  PLEASE HELP!
Title: Re: Font.CacheFontForText Causes Lag - NGUI Fonts
Post by: ArenMook on February 17, 2015, 10:22:34 PM
You say you aren't using dynamic fonts... yet you clearly are. Font.CacheFontForText is only called for dynamic fonts. "Font" is a Unity class. Unity's dynamic fonts suffer from a multitude of issues. This is one of them.

Stick to bitmap fonts if you want fast performance.
Title: Re: Font.CacheFontForText Causes Lag - NGUI Fonts
Post by: beermoney on February 18, 2015, 11:37:01 AM
when loading the game, I create a label with each glyph from the from the font at the size I'm going to be rendering the fonts at. ie. the label will never be displayed but contains the text aAbBcCdD...xXyYzZ123456 etc

This forces the dynamic fonts to be cached for me.

Be sure not to have "keep crisp" option off since that can also force the fonts to re-cache if the label ever scales.
Title: Re: Font.CacheFontForText Causes Lag - NGUI Fonts
Post by: guillopuyol on February 18, 2015, 12:25:14 PM
Thanks for the reply.  In my case, I had the Debug option of the NGUI camera turned on... When I turned that off the problem went away.