Author Topic: Animation or Tween an anchor object for multi resolution  (Read 9376 times)

tnbao91original

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 41
    • View Profile
Animation or Tween an anchor object for multi resolution
« 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Animation or Tween an anchor object for multi resolution
« Reply #1 on: March 10, 2015, 08:52:07 PM »
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').

tnbao91original

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 41
    • View Profile
Re: Animation or Tween an anchor object for multi resolution
« Reply #2 on: March 10, 2015, 09:07:39 PM »
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.

tnbao91original

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 41
    • View Profile
Re: Animation or Tween an anchor object for multi resolution
« Reply #3 on: March 10, 2015, 11:16:53 PM »
I construct my scene like this with UI Root setting Contrained, just only ContainerBottom (anchor center bottom) and ContainerTop (anchor center top)



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


When I anim this to left

In 4:3 mode this works fine (image below is exactly what I want)


But in 3:2 mode it's wrong position

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Animation or Tween an anchor object for multi resolution
« Reply #4 on: March 12, 2015, 07:41:52 PM »
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.

tnbao91original

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 41
    • View Profile
Re: Animation or Tween an anchor object for multi resolution
« Reply #5 on: March 12, 2015, 09:12:35 PM »
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 ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Animation or Tween an anchor object for multi resolution
« Reply #6 on: March 12, 2015, 09:27:24 PM »
Not using the animation system, no.

tnbao91original

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 41
    • View Profile
Re: Animation or Tween an anchor object for multi resolution
« Reply #7 on: March 13, 2015, 01:54:14 AM »
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 :)