Author Topic: When inactive device/Editor, NGUI animation animates quickly!  (Read 2950 times)

shinsugita

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
When inactive device/Editor, NGUI animation animates quickly!
« on: October 15, 2015, 08:51:10 PM »
Hi there.
I use NGUI. I attached UISpriteAnimation component to gameobject.

When I inactive UnityEditor, and wait for a moment.

And later, I go back UnityEditor, NGUI animation animates quickly.
the more I wait, the more quickly animation.

iPhone5s cause it also.

Could you tell me how to fix the bug? Or If I update NGUI it fix?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: When inactive device/Editor, NGUI animation animates quickly!
« Reply #1 on: October 18, 2015, 06:37:53 PM »
Change the Update function of UISpriteAnimation to be clamped like so:
  1.         protected virtual void Update ()
  2.         {
  3.                 if (mActive && mSpriteNames.Count > 1 && Application.isPlaying && mFPS > 0)
  4.                 {
  5.                         mDelta += Mathf.Min(1f, RealTime.deltaTime); // <-- this right here
  6.                         float rate = 1f / mFPS;
  7.  
  8.                         while (rate < mDelta) // <-- and this to a 'while' loop
  9.                         {
  10.                                 mDelta = (rate > 0f) ? mDelta - rate : 0f;
  11.  
  12.                                 if (++mIndex >= mSpriteNames.Count)
  13.                                 {
  14.                                         mIndex = 0;
  15.                                         mActive = mLoop;
  16.                                 }
  17.  
  18.                                 if (mActive)
  19.                                 {
  20.                                         mSprite.spriteName = mSpriteNames[mIndex];
  21.                                         if (mSnap) mSprite.MakePixelPerfect();
  22.                                 }
  23.                         }
  24.                 }
  25.         }

shinsugita

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: When inactive device/Editor, NGUI animation animates quickly!
« Reply #2 on: October 19, 2015, 05:05:15 AM »
Thank you for replying!

I could fix the animation.

Finally is it bug of NGUI?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: When inactive device/Editor, NGUI animation animates quickly!
« Reply #3 on: October 24, 2015, 04:27:16 AM »
Yeah it is. The fix I proposed will be in the next update too.