Author Topic: Anchors & Tweens  (Read 2231 times)

FizzPow

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
    • FizzPow Games
Anchors & Tweens
« on: December 07, 2012, 08:42:42 PM »
Running into an issue I hope I can get a better solution for.

I am trying to lay out my screen using anchors for everything so my UI looks correct on many different aspect ratios.  That is all working great.  The problem is, now I want to do some Tween animations to bring the objects on screen in various ways to build the screen.

I am trying to use HOTween.From() with a relative #, so that it ends up where it is already.  The problem is two-fold:

1) If I call this on Start(), the object is not at the correct anchor'd coordinates yet, so it ends up animating the wrong way
2) When the animation is done, the anchor snaps it back to where it should be

The solution I found that seems very in-elegant is to:

- Set the object's anchor in editor to have a high depth offset so its not visible
- In Start() Call Invoke() with a 0.1f delay so the anchor has time to set

Then In Invoked function

- Disable the objects anchor
- Set its Z back to 0 so its visible
- Then call my HOTween.From() method to animate it in

This works but is a ridiculous amount of steps.  Please tell me there is a better way?  Thanks!!  ;D

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Anchors & Tweens
« Reply #1 on: December 07, 2012, 09:46:07 PM »
If an object has an anchor, it should not be animated. Animate its child instead.

FizzPow

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
    • FizzPow Games
Re: Anchors & Tweens
« Reply #2 on: December 08, 2012, 01:48:02 AM »
Doh!  Yes, I just had to create a parent anchor gameobject and then tween the child, this works great, thanks =)