Author Topic: Bug: UILabel no longer takes spacing into account for Resize Freely dimensions  (Read 3729 times)

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Simple to reproduce: just make a label, type something ("lorem ipsum"), set label mode to Resize Freely, then drag the X spacing around. Previously, calculated widget size accounted for it, now it stays exactly the same no matter the spacing, leading labels to break on more and more lines as spacing grows:



It's probably related to new changes in NGUIText and UILabel, checking how simple it is to fix now.

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Seemed to be an easy fix, all you need to do to make it work again is to remove the strange check for finalSpacingX being negative before addition of spacing to width (which, for some reason, is only done for non-symbol branch). It's located in NGUIText.cs at line 1015. I changed that line like this:

  1. // if (finalSpacingX < 0f) w += finalSpacingX;
  2. w += finalSpacingX;

Which made everything work like it used to, as far as I can see:



Am I missing anything? What was the reason for disabling spacing influence on spacing values above zero?

P.S.: It's probably worth checking for character index and not adding spacing to the outermost character to prevent widget border growing needlessly on the outer edge, will do that next.

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Quote
P.S.: It's probably worth checking for character index and not adding spacing to the outermost character to prevent widget border growing needlessly on the outer edge, will do that next.
Turns out it's not possible to do that with simple index check (you need to modify quad size too, otherwise one will fall out to a new line), so disregard that. Some spacing-sized excess width on one side of a label doesn't hurt anyone.

Still curious why only negative spacing was allowed under updated NGUIText size calculation, though. :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
There was another thread where I posted the same exact fix earlier, so it's already resolved on my end and you will see it in the next update. Thanks though!