Support => NGUI 3 Support => Topic started by: Romulus on March 21, 2014, 09:25:19 AM
Title: Bug in UILable.
Post by: Romulus on March 21, 2014, 09:25:19 AM
Behavior of UILable has changed when Overflow option is set to ResizeHeight. If the value of UILable contains a word with length exceeding Dimensions X, UILable ignores the rest of the text and doesn't show it (truncates).
Title: Re: Bug in UILable.
Post by: ArenMook on March 21, 2014, 01:10:25 PM
Seems fine here.
1. New scene. 2. ALT+SHIFT+L 3. Changed text to "Testing" and Overflow to ResizeHeight. 4. Resized the width so that only "Test" shows. Works fine.
Title: Re: Bug in UILable.
Post by: makeshiftwings on March 22, 2014, 06:32:24 PM
I'm seeing the same bug as Romulus. Not sure what's causing it yet.
Title: Re: Bug in UILable.
Post by: makeshiftwings on March 22, 2014, 07:04:47 PM
I stepped through the code and see why it fails. In NGUIText.cs, line 874:
// Doesn't fit?
if(Mathf.RoundToInt(remainingWidth)<0)
{
// Can't start a new line
if(lineIsEmpty || lineCount == maxLineCount)
{
if(ch !=' '&&!eastern)
{
fits =false;
break;
}
If it reaches the max length of the line, and the character is not a space, it immediately breaks out of the for loop and returns fits = false. But the fits value is ignored by everything except ShrinkToFit. So the string buffer only contains the text it got to at that point, which truncates everything else, and never actually wraps the text either.
Title: Re: Bug in UILable.
Post by: makeshiftwings on March 22, 2014, 07:24:34 PM
FYI, I changed that "!eastern" to "eastern" and it works again. Of course I'm not using Eastern fonts, so I don't really know if that somehow breaks something else if you are using Eastern fonts; I couldn't figure out what that section of code was really trying to do. :B
Title: Re: Bug in UILable.
Post by: ArenMook on March 23, 2014, 02:42:45 AM
What's the text you're printing and how come am I not seeing any issues on my end with the steps I posted?
You can also try changing that code to:
// This is the first word on the line -- add it up to the character that fits