31
NGUI 3 Support / Re: 2 Bugs! Two UILabels + Advanced Anchors + ResizeFreely (with demo)
« on: November 24, 2014, 01:13:01 PM »I followed your instructions with your scene, and everything works as expected. The only thing I changed is I pixel-perfected your 2nd label. It had a position of 115.5 or something like that. It should have used integer values (ie: 115).
Clicking the randomize button changes the text, making the labels adjust right away. The 2nd label's right and bottom sides are left not anchored, meaning they stay exactly where they were.
Looking at your video I spotted the difference however. You set the 2nd label to also Resize Freely, which is not how it is in your example, and you didn't mention it in the steps either.
The problem occurs because of a combination of centered pivot and anchoring. Change the pivot to top-left, and the problem goes away. Reason for it is simple: when you enter text in a label, its dimensions can become uneven: ie: non-dividable by two. Centered pivot requires dimensions to be dividable by two, otherwise you get floating point values.
I've found another strange behaviour: the UILabel (pivot: top-left, text align: left, ResizeFreely, anchor: advanced-left-top to another UILabel with ResizeFreely) width will be wrong after i set a new text even if a call ProcessText() & ResetAndUpdateAnchors();
The right corners(top & bottom) will stay on prev positions while left corners will update and width will be incorrect.
Here is an example little bit tuned sources:
https://dl.dropbox.com/s/a3xr30fd9ht518j/NGUIAnchorsUILabel_Pack2.rar?dl=0



)
