Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: YD4k on August 09, 2012, 10:42:10 PM

Title: [bug]Some bugs found in NGUI 2.1.4 and earlier versions
Post by: YD4k on August 09, 2012, 10:42:10 PM
Hi Aren,

Found some bugs that might need a little fix:

1. NGUIMath.cs, CalculateRelativeWidgetBounds() will generate a wrong out put in 2.1.4, when no NGUI widgets were found in children of UITable.

in line 332:
  1. if (widgets.Length == 0) return new Bounds(root.position, Vector3.zero);
  2.  
should not use root.position since it's a "Relative" bound, might be a wrong copy&paste when upgrading to 2.1.4, older versions used Vector3.zero and that should be the right value for default.

2. UIFont.cs , WrapText() will miss calculate the width of some texts like "[System]" in the text, and it will be calculated as a color tag and leads to wrong line wrapping.

in line 602:
  1. offset +=7;
  2. continue;
  3.  

we should double check its a valid color tag. I used something like this:
  1. if (NGUITools.EncodeColor(NGUITools.ParseColor(text, offset + 1)) == text.Substring(offset + 1, 6).ToUpper())
  2. {
  3.      offset += 7;
  4.      continue;
  5. }
  6.  


3.NGUITools.cs, ParseSymbol(). Same bug happened here, when parsing color tags, should double check it
line 191:
  1. Color c = ParseColor(text, index + 1);
  2. c.a = colors[colors.Count - 1].a
  3. colors.Add(c);
  4.  

I used the same trick to fix that:
  1. Color c = ParseColor(text, index + 1);
  2.  
  3. if (EncodeColor(c) != text.Substring(index + 1, 6).ToUpper())
  4.     return 0;
  5.  
  6. c.a = colors[colors.Count - 1].a
  7. colors.Add(c);
  8.  
Title: Re: [bug]Some bugs found in NGUI 2.1.4 and earlier versions
Post by: ArenMook on August 09, 2012, 10:45:11 PM
Thanks!