Author Topic: Tween with duration 0 issue  (Read 6149 times)

Mistborn

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
Tween with duration 0 issue
« on: January 10, 2016, 09:38:16 PM »
The tween with duration 0 is malfunctioning since updated from 3.9.6 to 3.9.6c. I found out that the mFactor in UITweener.Update now always is 0 in the first update, which causes tween nothing.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tween with duration 0 issue
« Reply #1 on: January 11, 2016, 05:29:38 PM »
Add "if (duration == 0f) return 1000f;" to UITweener.amountPerDelta:
  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.         }
« Last Edit: January 11, 2016, 06:21:32 PM by ArenMook »

Mistborn

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: Tween with duration 0 issue
« Reply #2 on: January 12, 2016, 12:08:43 AM »
Thanks you for quickly reply. I tried the fix you provide, but it still tween nothing. Actually no mater the value of amountPerDelta is the mFactor always be 0 because of 0 delta in the first update.

  1.         if (!mStarted)
  2.         {
  3.                 delta = 0;
  4.                 mStarted = true;
  5.                 mStartTime = time + delay;
  6.         }
  7.  
  8.         if (time < mStartTime) return;
  9.  
  10.         // Advance the sampling factor
  11.         mFactor += amountPerDelta * delta;
  12.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tween with duration 0 issue
« Reply #3 on: January 13, 2016, 07:10:06 PM »
Ah yes, I see what you mean. Well, just change the factor increment line to:
  1. mFactor += (duration == 0f) ? 1f : amountPerDelta * delta;

Mistborn

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: Tween with duration 0 issue
« Reply #4 on: January 13, 2016, 09:35:02 PM »
Works perfectly! Thanks you so much!