Author Topic: tweening entire panels that have anchors inside of them?  (Read 7090 times)

tayl0r

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
tweening entire panels that have anchors inside of them?
« on: July 18, 2012, 12:17:05 PM »
Hello,

I have been fiddling with this for the past few hours and it doesn't seem doable without some nasty hacks so I'm assuming there is a better way to do what I'm trying to do. I also looked through all the tutorial / demo scenes and none of them seem to do this.

I have my normal game UI and then I have additional dialogs that pop up due to some user action. Those dialogs are full screen and have anchors inside of them so I can align the widgets and have the dialog still look right and be fullscreen on ipad / iphone / various resolutions.

But because those dialogs have anchors in them, I can't figure out how to properly tween them on & off the screen. I could just tween the alpha but I would rather translate / rotate / scale them. Is there a better way to do what I'm trying to do?

One hacky way I thought of would be to disable all the anchor scripts on the panel right before I do the tween, then re-enable them afterwards. This seems like it would work, but again, I have a feeling there is a more "NGUI" way to do it.

Another way I thought of would be to individually tween each anchor's relative offset property or the child of the anchor but that would lead to a ton of tweens and it would be much easier if I could just tween the root dialog. This would also mean I would be limited to translation in my tween since the various dialog components would not all rotate or scale together as one unit.

So, any ideas?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: tweening entire panels that have anchors inside of them?
« Reply #1 on: July 18, 2012, 02:17:51 PM »
Simple rule of using anchors... if you use an anchor, you should never tween or animate anything above that anchor, nor the anchor itself. Only child objects. The reason is obvious and you've ran into it -- anchor always tries to reposition its game object. That's what the script is supposed to do, after all.

Disabling anchors would be one way. Another, better way, is to animate panels below your anchors separately. For example in Windward I have dialogs anchored to the center, left, and right, and all animate independently of one another. If I want to show more than one, I simply play more than one animation, moving them into view.

pedroathumanspot

  • Guest
Re: tweening entire panels that have anchors inside of them?
« Reply #2 on: April 25, 2013, 01:36:45 AM »
Hi, hello.

Simple rule of using anchors... if you use an anchor, you should never tween or animate anything above that anchor, nor the anchor itself. Only child objects.

I might be getting it wrong but, that seems like a pretty nasty drawback.

Imagine that I have a modal popup, a panel, with sub-widgets with anchors which I use to position them relative to the modal window background widget/texture - I set the widget container in every of those anchors to the modal window background texture.

Imagine I want to bring that panel in from off-screen to the view. From what you are telling, we can't animate anything above an anchor. So, from your reasoning, it not be wise to move that modal window - with the sub-anchors active - right? If true, that's a bummer.

If so, what's the best/recommended way to accomplish this.

Cheers. :)

pedroathumanspot

  • Guest
Re: tweening entire panels that have anchors inside of them?
« Reply #3 on: April 25, 2013, 01:47:33 AM »
And I found out that someone, in http://www.tasharen.com/forum/index.php?topic=2317.0, made a UITweener that tweens the Anchor's Offset which seems the absolutely right way to do it and solves the previously stated problem. :)

I'm assuming tweening the offset of an anchor would be more than reasonable.

Anyway, that 'best practice' of not tweening stuff that has sub-widgets with anchors in them still didn't quite made sense here... :/

Cheers.

Pangamini

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: tweening entire panels that have anchors inside of them?
« Reply #4 on: September 04, 2013, 08:10:56 AM »
Is it possible to have anchors linked to something else than camera? It would be very useful, for example with resizable windows (and content of the window being anchored to its borders)

Sandsnake

  • Guest
Re: tweening entire panels that have anchors inside of them?
« Reply #5 on: September 04, 2013, 10:29:23 AM »
You can add an anchor script to any GameObject

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: tweening entire panels that have anchors inside of them?
« Reply #6 on: September 04, 2013, 06:15:25 PM »
I modified the UIAnchor so I could make it only work on one axis, so if I want to tween a page in from the side, I can anchor my thing on the Y axis and not be bothered that it will move funkily. That's always an option.

You can anchor to widgets, just pull the widget into the Widget Container property on the anchor's inspector.