Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Emirk on May 21, 2014, 03:47:57 PM

Title: [Potiential feature-request] How do I tween the position relative to a target?
Post by: Emirk on May 21, 2014, 03:47:57 PM
Let's say I have a UISprite in the middle of my screen. I'd like to animate this sprite to move from the left side of the screen to the right side - independent of screen pixel width. How do I do that? As I understand it, the current TweenPosition script only animates absolute values. If there's no way to animate an object relative to the positioning of some other object, then the tween position scripts are useless unless you're only targeting an exact pixel resolution.

The new Anchor system is great and it's lets us build UIs that work across different resolutions. When using Unified anchors, one can specify relative to what UIWidget you want to position your element. I'd like something similar for Tweens: The ability to specify from and to percentages relative to a specific UIWidget. That would make various Tween scripts much more useful.

Is there any way to do this today that I'm missing? If not, will it ever be added to NGUI?

Thanks for a great plugin!
Title: Re: [Potiential feature-request] How do I tween the position relative to a target?
Post by: Nicki on May 21, 2014, 04:41:22 PM
Well, essentially you'd have to calculate the absolute position from your relative thing. Say, you want it to move to another widget with a certain offset - then you need to have a controller script with a reference to that target, and use its localPosition+offset as the target for the tweener.
Title: Re: [Potiential feature-request] How do I tween the position relative to a target?
Post by: ArenMook on May 21, 2014, 04:45:21 PM
You can always use TweenTransform for something like that.