Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: dominus85 on February 21, 2014, 07:43:53 AM
-
Until now, if I had a width W widget, i used to offset from rights target for left and right:
for left: OFFSET
for right: OFFSET + W
I think this is not an elegant way of dealing with offseting widgets and I would be grateful for a better solution. I simply want the right edge of my widget to be at an OFFSET distance of a target, even if the widget width changes. Is there a simple way to do this without calculating the left and right offsets based on the widget width?
Since upgrading to 3.5.0b I am not sure the way I use still works
If I change the width of the widget used as Unified Anchor(let's call it reference), to widgets that are anchored to it will no longer change their position. They simply stay in the same place and the Left and Right constraints change accordingly. However, if I change the widget dimensions from editor, it works :)
I think the change that broke the functionality is this: https://github.com/tasharen/ngui/commit/1618d32c3e63d00146746df77f8f8d0bead40b09#diff-89a3fb27e36824b406e234bfeb9dcda3
-
If you want something to be anchored to the right, with a resizable width, anchor both left and right side of the widget, but change the pivot to top-right, right, or bottom-right.
You will be able to resize its width and since the pivot is on the right, it will adjust its position by expanding toward the left.
-
Makes sense, your suggestion.. Will try
Now, regarding the bug I am describing above, here is the repro case https://www.dropbox.com/s/nzay2tvxvspiszo/tween_constraints.zip
the X sprite is anchored to the left of the button sprite..
i change the width of the button sprite with a tween width
if a tween is playing in the same time on X, X will not update its position based on the anchor constraints, but instead changes the constraints
if no tween is playing on X, the behaviour is as expected, with X moving along with the button
-
Tweens adjust the anchors, this is intentional.
-
I think this should be a toggle, so I can choose the default behaviour.. I do not always want this behaviour to happen
-
If this doesn't happen, then nothing will happen when you tween, because the anchor will overwrite the tween's logic.
-
Ok.. for anyone else having the same issue, the workaround is to create an empty GameObject as parent of the second Tweened element.