1
NGUI 3 Support / Solving anchored + animated widgets
« on: May 04, 2015, 02:17:24 PM »
After running into another case where I need anchored and animated widgets, I've come to the conclusion that NGUI needs to address this fairly common requirement and how it can be reconciled with the current anchoring system. The main issue arises due to the fact that it is no longer possible to match a widget's dimensions without also taking its position. The legacy components UIAnchor and UIStretch provided that ability. Here's an example that illustrates the problem:
Widget A (anchored to fill the left 1/4 of the screen)
- Various UI elements (anchored to Widget A in order to have correct dimensions/relative spacing)
Now what can I do to slide these elements on-screen from the left?
- I can't apply a TweenPosition to Widget A because its anchoring will override the tween.
- I can't apply TweenPositions to the sub-elements, because they still need to accept the dimensions from Widget A
My proposed solution is to add a control to UIRect that allows the user to toggle position and/or dimension matching. This new enum (or checkboxes) has three possible states: Position, Dimensions, or PositionAndDimensions. The only change in behaviour is that right before overwriting localPosition or mWidth/mHeight in UIWidget.OnAnchor:1231/1238, we check that we have an acceptable AnchorMode.
I believe this change to be low-risk, backward-compatible (default to PositionAndDimensions), and easy to communicate. Please let me know what you think.
Widget A (anchored to fill the left 1/4 of the screen)
- Various UI elements (anchored to Widget A in order to have correct dimensions/relative spacing)
Now what can I do to slide these elements on-screen from the left?
- I can't apply a TweenPosition to Widget A because its anchoring will override the tween.
- I can't apply TweenPositions to the sub-elements, because they still need to accept the dimensions from Widget A
My proposed solution is to add a control to UIRect that allows the user to toggle position and/or dimension matching. This new enum (or checkboxes) has three possible states: Position, Dimensions, or PositionAndDimensions. The only change in behaviour is that right before overwriting localPosition or mWidth/mHeight in UIWidget.OnAnchor:1231/1238, we check that we have an acceptable AnchorMode.
I believe this change to be low-risk, backward-compatible (default to PositionAndDimensions), and easy to communicate. Please let me know what you think.

, where a repeating texture has its UV coordinates animated to create a scrolling effect. I understand that for the repeating part I should use a UITiledSprite, but that doesn't help me with the UV offsetting. Is there any way of assigning an offset manually, or will I have to modify the UITiledSprite class?