Author Topic: UITweener issue with repeated calls to PlayForward and PlayReverse  (Read 4345 times)

kittikun

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 5
  • Posts: 46
    • View Profile
Hi,

I have been using a lot of tweens to animate my UI with a lot of PlayForward and PlayReverse, depeding on the state of the game and I've been running into various problems

To easily test, please modify UITweener.cs to add a context menu to them

  1.         [ContextMenu("PlayForward")]
  2.         public void PlayForward()
  3.  
  4.         [ContextMenu("PlayReverse")]
  5.         public void PlayReverse()[/td]
  6.  

Then create a simple scene with a sprite and a tween position

- The tween will run when you start the scene
x Play Reverse, the item "jumps" to From
x Play Format, same as play reverse

Is the way I am using it wrong ?

I found the following workaround to be working:

  1.         public static void Play(this TweenPosition tween, Vector3 from, Vector3 to, float duration)
  2.         {
  3.                 tween.from = from;
  4.                 tween.to = to;
  5.                 tween.duration = duration;
  6.                 tween.ResetToBeginning();
  7.                 tween.ignoreTimeScale = false;
  8.                 tween.PlayForward();
  9.         }
  10.  

But I will still have problems after call PlayReverse() so I have to addcomponent tween and destroy them during onEnable and onDisable/

Also sometimes, OnFinished is not correctly called

Is something wrong with my usage ?
« Last Edit: May 16, 2014, 05:18:11 AM by kittikun »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITweener issue with repeated calls to PlayForward and PlayReverse
« Reply #1 on: May 16, 2014, 01:30:31 PM »
Nothing jumps when I play forward or reverse. All the PlayForward or PlayReverse functions do is call Play inside, and that function simply sets the "amount per delta" and re-enables the script, letting it play. It doesn't reset the current position. If you call PlayReverse halfway through playing it forward, it will simply reverse the direction.

What version of NGUI are you using?

kittikun

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 5
  • Posts: 46
    • View Profile
Re: UITweener issue with repeated calls to PlayForward and PlayReverse
« Reply #2 on: May 17, 2014, 11:33:32 AM »
Strange, this I have been having this issue for a while now

I'm currently on 3.5.8

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile

kittikun

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 5
  • Posts: 46
    • View Profile
Re: UITweener issue with repeated calls to PlayForward and PlayReverse
« Reply #4 on: June 02, 2014, 01:48:06 AM »
Nevermind, I don't have time to debug this properly to propose a fix so I just decide to use iTween