Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: jrhee on August 30, 2016, 12:26:38 PM

Title: UITweener bug
Post by: jrhee on August 30, 2016, 12:26:38 PM
Hey Aren,

I ran into an issue with using the Tween functions in this block (3.10, UITweener.cs):

  1.         public float amountPerDelta
  2.         {
  3.                 get
  4.                 {
  5.                         if (duration == 0f) return 1000f;
  6.  
  7.                         if (mDuration != duration)
  8.                         {
  9.                                 mDuration = duration;
  10.                                 mAmountPerDelta = Mathf.Abs(1f / duration) * Mathf.Sign(mAmountPerDelta);
  11.                         }
  12.                         return mAmountPerDelta;
  13.                 }
  14.         }
  15.  

When reusing a tweener and switching between a zero and non-zero duration, mDuration doesn't update correctly, causing mAmountPerDelta to lock at 1000.

For example:

TweenScale.Begin - duration = 1, mDuration = 1, amtPerDelta = 1 - OK
TweenScale.Begin - duration = 0, mDuration = 1, amtPerDelta = 1000 - mDuration should've changed to 0, this will become a problem on the next run
TweenScale.Begin - duration = 1, mDuration = 1, amtPerDelta = 1000 - amtPerDelta isn't updated since duration == mDuration, subsequent transitions occur instantaneously

Let me know if this isn't clear, thanks!
Title: Re: UITweener bug
Post by: ArenMook on August 30, 2016, 09:39:25 PM
UITweener.Begin -- just add mDuration and mAmountPerDelta setting directly:
  1. comp.mDuration = duration;
  2. comp.mAmountPerDelta = duration > 0f ? Mathf.Abs(1f / duration) : 1000f;