Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Erhune on January 22, 2014, 01:50:09 PM

Title: Setting UILabel.text doesn't compute the size instantly
Post by: Erhune on January 22, 2014, 01:50:09 PM
Between 3.0.0 and 3.0.6, it used to be that setting a UILabel.text would compute the UILabel.width and UILabel.height right now. I used this all the time to compute my layout in many parts of my GUI. Now, I have to do that in a coroutine: set the text, yield until the next frame when the width and height will be computed, and reposition everything. Of course, that means I have a 1-frame flicker which I didn't have before.

I understand this computation must be delayed for performance reasons, but isn't there a way to force it? Something like UILabel.ComputeSizeNow()...
Title: Re: Setting UILabel.text doesn't compute the size instantly
Post by: ArenMook on January 23, 2014, 06:43:59 AM
You can do immediately like so:
  1. UILabel lbl = GetComponent<UILabel>();
  2. lbl.UpdateNGUIText();
  3. NGUIText.CalculatePrintedSize(...);