Author Topic: Need NGUI 3.0 Label vertical align fix, please  (Read 5011 times)

bdominguez

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 38
    • View Profile
Need NGUI 3.0 Label vertical align fix, please
« on: September 13, 2013, 04:22:16 AM »
Hi Aren,

In the release notes there is a: "FIX: Labels will now again align vertically properly."

Do you mean when you use "maxHeight" with a value different that 0? It's actually my problem.

I asign the pivot to be vertically in the center but it's always in top.

Can you tell me what lines I have to change? Or the "UILabel.cs" file.

Thanks!!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Need NGUI 3.0 Label vertical align fix, please
« Reply #1 on: September 13, 2013, 09:03:27 AM »
In 2.7.0 the labels would always align to the top. In 3.0.0 they get centered vertically again, if the pivot is center, and bottom-aligned if the pivot is bottom.

N3uRo

  • Guest
Re: Need NGUI 3.0 Label vertical align fix, please
« Reply #2 on: September 13, 2013, 11:03:10 AM »
In 2.7.0 the labels would always align to the top. In 3.0.0 they get centered vertically again, if the pivot is center, and bottom-aligned if the pivot is bottom.

I don't know when you are going to release 3.0 to the Asset Store so that's why I said if you can share the code to fix that. I don't know If it's only on UILabel or because you change more things we can't use it with 2.7.0.

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Need NGUI 3.0 Label vertical align fix, please
« Reply #3 on: September 13, 2013, 12:25:09 PM »
It's not that simple. 3.0's code is vastly different from 2.7's. Here is the (slightly modified) code that fixed it in 3.0:
  1.         // Center vertically
  2.                 float offsetY = Mathf.Lerp(mSize.y * scale - mHeight, 0f, pivotOffset.y);
Getting it to work for 2.7 you'd need to use mMaxWidth and mMaxHeight insidead as I recall, and after this section you have to iterate through all the vertices in the vertex buffer and offset them by the 'offsetY ' value.