Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: tnbao91original on March 10, 2015, 11:58:46 AM
-
Hi ArenMook,
May you show how to anim or tween anchor object ? I try tweening object, it work (just anchor Enable) but the position is difference in another resolutions.
How to do like this ?
http://ge-team.com/pages/unity-3d/gui-animator-for-ngui/
Thank.
-
That depends on what settings you chose on your UIRoot. If it's Constrained, then it will be the same size regardless of the resolution and anything you set up will just work. If it's Flexible, then your UI will need to be adjusted to begin with -- such as by using anchoring. I'm going to assume you are asking about that. TweenPosition works in local space by default (meaning virtual pixels). It can be set to use world space coordinates via code. When you are initiating your tween via TweenPosition.Begin, you get a reference to the tween. You can then set worldSpace = true; and use world coordinates.
Alternatively, knowing the desired relative from and to positions, convert them from desired relative space (0.5 meaning "middle" for example) to screen space (multiplying by screen width or height), then use NGUIMath.ScreenToPixels to make it relative to the widget's parent. You can then tween that widget as you normally would (without changing worldSpace to 'true').
-
Thank you for quick support. Can you make a simple example ? I cann't find any example in your plugin about this issue. Because I'm newbie and many people in here same too so it's very useful for us.
-
I construct my scene like this with UI Root setting Contrained, just only ContainerBottom (anchor center bottom) and ContainerTop (anchor center top)
(http://s7.postimg.org/u8cio3xp7/image.png)
Example with my ContainerBottom, I have a clip anim move all children of it from bottom to left but seem to be that not correct in many differen resolution
Init state correct with all resolution
(http://s9.postimg.org/rs3o8xwmn/image.png)
When I anim this to left
In 4:3 mode this works fine (image below is exactly what I want)
(http://s8.postimg.org/odryzrtr9/image.png)
But in 3:2 mode it's wrong position
(http://s8.postimg.org/5s3ga5279/image.png)
-
Easiest way to do what you want here is to have invisible widgets anchored both to the bottom and to the side. Then you have actual visible sprites that will tween from one widget's position to another. Since both of the widgets are anchored, the sprite will appear to be anchored as well, when in fact it won't be.
-
Yup I know that way but my task is not easy like that. I have to use animation system with keyframe to make animate so my artist team can join and work together with us. Definitely tween system can't work like aniamtion system. Anyway else ?
-
Not using the animation system, no.
-
uGUI support use animation system with Anchor x y z and Anchor position so we can anim widgets without init 2 empty anchor widgets (start, end). It's good if NGUI can do this too :)