Right then. Thought I'd update my UI to use the new anchoring system in 3.0.7, and make them more consistent at the same time.
I've ran into an issue. It seems anchoring and stretching have become one.
My UI design - based on an earlier NGUI example - has various 'cards' that animate in and out for different sections of the menu.
The cards have a strip at the top (UISprite), and a line of text for the card title (UILabel).
Each card has a background UISprite.
The cards themselves have differing widths and heights depending on how much content they have.
I would like the strip to be anchored at the top of the card, and run the full width of the card.
However, I would like all the strips to be the same height as each other.
The new anchoring is great at making my card title (UILabel) fit in the middle of my UISprite.
Unfortunately, I can't see how I *stop* stretching when I don't want it.
EDIT: Now I can see how I specify a size, which is good enough. See below
Let's say I want all my top stripes to be 50px tall.
With Anchors set to...
None: I can simply set the Y Dimension of my UISprite to 50 - but I need to enter the correct X dimension and set the Y transform position manually so it is at the top of my 'card'. I can work this all out based on the card size, but I'd prefer to use anchoring.
Padded, and a target of the card UISprite (which happens to be 500 tall), the settings are automatically worked out as being left 0, right 0, bottom 450, top 0. I'm therefore specifying the amount of pixels that are *not* taken up by the strip - the margin sizes, not the content size. Meaning that if I made the card bigger, I'd need to recalculate that bottom if I want the stripe to stay at 50px tall and not stretch in height with the card.
Relative, everything is explicitly based upon multiples of the target's size. Fine in the X dimension but not the Y.
Unified, I can mix and match between setting things as a multiple of the target or by a pixel margin.
EDIT: And I can set minus margins, if I set the right target multiplier! Woo. This is the solution.
Advanced, I can change things like I can in Unified except I can change the target for each side.
With any of these Anchor modes on, I can no longer set the Y Dimension - it springs back to the value calculated by the anchoring. So anchoring and stretching have been combined. This has many uses, but doesn't help this situation.
I do want to position and stretch in the X dimension, but I only want to position in the Y. I want to specify the height of the sprite and not have it changed by Anchoring.
I know I can design my background UISprite to include the top strip in the slicing, which would be represented faithfully in a specific number of pixels. But then I would be faced with the problem of getting my UILabel to anchor in the middle of the top strip without stretching.
The item that my scaling is a multiple of and the item to which I am anchoring are not always going to be the same thing, but it seems Anchors assumes it is. Am I missing something?