Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Nubeh on October 28, 2013, 07:45:15 AM

Title: UILabel text with color bug in 3.0.3?
Post by: Nubeh on October 28, 2013, 07:45:15 AM
Hi there,
I had this code working last week where I was setting the text on a UILabel using a color variable for the text color like this:

myLabel.text = "["+color+"]"+mytext+"[-]"

but after updating to NGUI 3.0.3 I get this error:

ArgumentOutOfRangeException: startIndex + length > this.length
Parameter name: length
System.String.Substring (Int32 startIndex, Int32 length) (at /Applications/buildAgent/work/c514da0c8183631c/mcs/class/corlib/System/String.cs:356)
NGUIText.WrapText (System.String text, UnityEngine.Font font, Int32 size, FontStyle style, Int32 width, Int32 height, Int32 maxLines, Boolean encoding, System.String& finalText) (at Assets/NGUI/Scripts/Internal/NGUIText.cs:414)
UILabel.ProcessText (Boolean legacyMode) (at Assets/NGUI/Scripts/UI/UILabel.cs:800)
UILabel.ProcessText () (at Assets/NGUI/Scripts/UI/UILabel.cs:762)
UILabel.ProcessAndRequest () (at Assets/NGUI/Scripts/UI/UILabel.cs:296)

I also enabled on the UILabel the ShrinkContent option with Crisp Always.

Does anybody else have the same issue?
Title: Re: UILabel text with color bug in 3.0.3?
Post by: Mauri on October 28, 2013, 03:53:53 PM
Same Issue here.
Title: Re: UILabel text with color bug in 3.0.3?
Post by: Darkmax on October 28, 2013, 04:31:09 PM
I know this doesn't resolve completely the problem, for the cases where you have more than one color on one label, but if you have just one color on one label you can use UILabel.color for the time being
Title: Re: UILabel text with color bug in 3.0.3?
Post by: gdeglin on October 28, 2013, 06:35:15 PM
Same bug here.
Title: Re: UILabel text with color bug in 3.0.3?
Post by: ArenMook on October 29, 2013, 12:09:10 AM
Confirmed, will fix.
Title: Re: UILabel text with color bug in 3.0.3?
Post by: ArenMook on October 29, 2013, 12:32:47 AM
You can fix it locally by replacing line 354 in NGUIText. Currently it is:
  1. if (ParseSymbol(text, ref offset)) continue;
It should be:
  1. if (ParseSymbol(text, ref offset)) { --offset; continue; }
Title: Re: UILabel text with color bug in 3.0.3?
Post by: Nubeh on October 29, 2013, 04:24:48 AM
It works...BUT, there's another bug with this fix. The text is set to ShrinkContent but now it doesn't shrink and in my case it goes out of my screen. The dynamic coloring works.
Title: Re: UILabel text with color bug in 3.0.3?
Post by: ArenMook on October 29, 2013, 04:16:23 PM
It's a different bug, and I am aware of it. I just haven't gotten around to fixing it as it's not super-critical (and because I keep forgetting <_<).