Author Topic: UILabel reverse word wrap  (Read 4117 times)

SirManGuy

  • Guest
UILabel reverse word wrap
« on: December 17, 2013, 02:37:48 AM »
I've started up a new project and started migrating some pieces. I started adding my message box system but ran into an interesting issue of word wrap not quite working as I expected. As you can see from the attached images my text is going up for every carriage return (or word wrap) instead of down! I've captured my settings on the UILabel. I've searched on the forums here and havent noticed anyone else with the issue so I'm guessing I've messed up the set up in the new project. I'm running 3.0.7f and Unity 4.3.1, any help would be grateful!

SirManGuy

  • Guest
Re: UILabel reverse word wrap
« Reply #1 on: December 17, 2013, 02:59:30 AM »
Okay after a quick investigation between 3.0.3 and 3.0.7 in the NGUIText.cs there was some changes to how the baseline is calculated and how the y values are changed. I've put in a quick hack for myself listed below that just reverses how the lineheight effects the y position.

  1.                         if (c == '\n')
  2.                         {
  3.                                 if (x > maxX) maxX = x;
  4.  
  5.                                 if (current.alignment != TextAlignment.Left)
  6.                                 {
  7.                                         Align(verts, indexOffset, x - spacingX);
  8.                                         indexOffset = verts.size;
  9.                                 }
  10.  
  11.                                 x = 0;
  12.                                 y -= lineHeight;
  13.                                 continue;
  14.                         }
  15.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel reverse word wrap
« Reply #2 on: December 17, 2013, 12:17:59 PM »
Make sure you have the latest version. This bugged version existed for only an hour before it was patched.

SirManGuy

  • Guest
Re: UILabel reverse word wrap
« Reply #3 on: December 18, 2013, 11:52:49 PM »
Hahah I have the worst timing! Thanks Aren