Author Topic: TweenPosition works only once  (Read 6445 times)

luisdiv

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 32
    • View Profile
TweenPosition works only once
« on: October 15, 2012, 09:50:12 AM »
Hi,

Congratulations on the release of Winward!

I need to bother you asking for help with a certain issue

I have a NGUI menu which is supposed to move on click. Its composed of 7 panels which act as buttons, as they have colliders and a script with an OnClick function. They also have TweenPosition components, deactivated from start, and activated on click.

  1. // This goes in the OnClick function of every panel
  2. foreach(GameObject obj in panelsArray) {
  3.         TweenPosition tweenpos = obj.GetComponent<TweenPosition>();
  4.         tweenpos.from = obj.transform.localPosition;
  5.         tweenpos.to = new Vector3(obj.transform.localPosition.x-735, obj.transform.localPosition.y, obj.transform.localPosition.z);
  6.         tweenpos.Play(true);
  7. }

I made this to slide all panels 735 pixels left every time I click any of them. The problem is it only tweens once, after that, when I click on them they only reposition without sliding.

Thanks in advance!

Luis


JRoch

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 140
    • View Profile
Re: TweenPosition works only once
« Reply #1 on: October 15, 2012, 11:34:49 AM »
I always call a .Reset before a .Play of a Tween where I'm modifying the start and end values.  I'm (reasonably) certain that after a .Play(true) you can only call a .Play(false) unless you issue a .Reset

luisdiv

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 32
    • View Profile
Re: TweenPosition works only once
« Reply #2 on: October 15, 2012, 06:04:12 PM »
I had already answered back to say it worked.. Either my reply was deleted or never sent.

The Reset() function worked, thanks!  ;D