The Anchor system in NGUI is very nice but I need a bit more flexibility to get the layouts I need. In particular, I noticed that the Unified anchor doesn't play nice when there are modifications to the Scale part of the Transform.
Bug report: Unified Anchor does not account for Transform Scale.
If a Sprite has an X and Y scale of 2, then it will expand and contract at twice the rate that the anchor expects. This is likely because the anchor is just looking at the dimensions and not the transform. There is also a problem in the editor when switching a scaled Sprite from no anchor to the unified anchor; it gets blown out of size and out of position, and doesn't return when you set the anchor back to "none".
You might ask why I'm using Transform Scale on a Sprite that is anchored (since the anchor can resize the dimensions). It's true that anchors themselves can take care of the scaling in most cases, but this isn't always what you want for sliced sprites. In my project the UIRoot is set to a FixedSize Scaling Style with a manual height of 1536 in order to target the highest resolution tablets while also accommodating the lowest. This is necessary for crisp fonts etc at high res, but it also means exporting our UI textures at those resolutions, which takes up a lot of space in the atlas and isn't often necessary for those textures to look good. My solution is to store them at medium resolution in the atlas and adjust the X and Y scale in the Transform to bring them up to the proper size. This even works for sliced assets and I think is a sensible process but unfortunately it confuses the anchors.
I'm hoping this will not be too hard to address with some modifications to UIAnchor.cs but I wanted to post here before digging into that. Has anyone attempted this before?
Also I have a closely related feature request, unless there's some way to do this that I haven't thought of. I would like to be able to anchor to a position identified by a percentage of the target's width or height, instead of an absolute offset. For example, I have a horizontal divider and I want the left side to be anchored to the left side of its parent, but at a position of 25% of its width. This means that visually it will appear at the quarter-way mark whether it is viewed on a 16:9 screen or a 4:3 screen.
These two changes together can help a lot for developers who want the UI to be as consistent as possible across devices. Again, I'm willing to contribute to implementing/testing these changes.
Thanks
-Devan