Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: pfranza on June 26, 2013, 08:58:35 AM

Title: Tween Between Anchor Positions
Post by: pfranza on June 26, 2013, 08:58:35 AM
I have been looking for a solution for a little while and everything I find just seems a little bit to weird so I'm not sure I'm thinking about it correctly.

I have a panel that is anchored to the top-left, and I want to be able to temporarily tween the position so that it slides to the center of the screen (and potentially back to its original position)

I've been trying to do the calculations using the panel offsets but always seem to be wrong when using different screen resolutions. 

Is there a best practice for attacking this problem?  Does anybody have a code snippet they could share?
Title: Re: Tween Between Anchor Positions
Post by: Nicki on June 26, 2013, 10:48:16 AM
I think the easiest would be to look into the UIAnchor code and use the way it is calculating positions to calculate the target for your tween, instead of using actual UIAnchors.
Title: Re: Tween Between Anchor Positions
Post by: tripclaw on June 26, 2013, 02:31:14 PM
I think you could just add a child to the anchor, the child should have UILagPosition, and then everything else becomes a child of that. Then just set the anchor to Top, Center, etc. and it should "tween" there using the LagPosition...

Title: Re: Tween Between Anchor Positions
Post by: Malzbier on June 27, 2013, 02:36:40 AM
For a slide out menu i created a script that uses 2 empty gamobject with anchor for getting the proper slided in and out positions.

Just tween between the position between the position of though gamobjects.

At start i did set the position delayed by one frame to one of the gamobjects positions.