Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: shinsugita on October 15, 2015, 08:51:10 PM

Title: When inactive device/Editor, NGUI animation animates quickly!
Post by: shinsugita 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?
Title: Re: When inactive device/Editor, NGUI animation animates quickly!
Post by: ArenMook 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.         }
Title: Re: When inactive device/Editor, NGUI animation animates quickly!
Post by: shinsugita on October 19, 2015, 05:05:15 AM
Thank you for replying!

I could fix the animation.

Finally is it bug of NGUI?
Title: Re: When inactive device/Editor, NGUI animation animates quickly!
Post by: ArenMook on October 24, 2015, 04:27:16 AM
Yeah it is. The fix I proposed will be in the next update too.