Author Topic: UILabel text with color bug in 3.0.3?  (Read 3166 times)

Nubeh

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 41
    • View Profile
UILabel text with color bug in 3.0.3?
« 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?

Mauri

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: UILabel text with color bug in 3.0.3?
« Reply #1 on: October 28, 2013, 03:53:53 PM »
Same Issue here.

Darkmax

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 93
    • View Profile
Re: UILabel text with color bug in 3.0.3?
« Reply #2 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

gdeglin

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 18
    • View Profile
Re: UILabel text with color bug in 3.0.3?
« Reply #3 on: October 28, 2013, 06:35:15 PM »
Same bug here.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel text with color bug in 3.0.3?
« Reply #4 on: October 29, 2013, 12:09:10 AM »
Confirmed, will fix.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel text with color bug in 3.0.3?
« Reply #5 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; }

Nubeh

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 41
    • View Profile
Re: UILabel text with color bug in 3.0.3?
« Reply #6 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel text with color bug in 3.0.3?
« Reply #7 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 <_<).