Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: vallcrist on December 18, 2013, 12:45:33 PM

Title: UITextList not accounting for font spcaing
Post by: vallcrist on December 18, 2013, 12:45:33 PM
UITextList does not account for vertical spacing in the fonts, so if you have a 200 px height textbox with a 12px height font and 4 px of vertical spacing it will try to fit 16 lines ( 200/12 ) when it only fits 12 ( 200 / (12+4) )
Title: Re: UITextList not accounting for font spcaing
Post by: ArenMook on December 18, 2013, 12:48:19 PM
Thanks, you can resolve this by changing UITextList.lineHeight property to the following:
  1. protected float lineHeight { get { return (textLabel != null) ? textLabel.fontSize + textLabel.spacingY : 20f; } }
Title: Re: UITextList not accounting for font spcaing
Post by: vallcrist on January 20, 2014, 04:44:48 PM
Hey Michael, just stumbled on this error again today as i was redoing the chat in our game, seems like you forgot to add the in the updates, just bumping this up so you see it again. :)

You did update the lineHeight property, but you forgot to change it in the UpdateVisibleText method.

Line 299 of UITextList
  1. int maxLines = Mathf.FloorToInt((float)textLabel.height / textLabel.fontSize);
  2.  

should be

  1. int maxLines = Mathf.FloorToInt((float)textLabel.height / lineHeight);
  2.  
Title: Re: UITextList not accounting for font spcaing
Post by: ArenMook on January 21, 2014, 01:23:39 AM
You're right, thanks -- but you should also modify 'scrollHeight' too.
  1.         protected int scrollHeight
  2.         {
  3.                 get
  4.                 {
  5.                         if (!isValid) return 0;
  6.                         int maxLines = Mathf.FloorToInt((float)textLabel.height / lineHeight);
  7.                         return Mathf.Max(0, mTotalLines - maxLines);
  8.                 }
  9.         }