Support => NGUI 3 Support => Topic started by: doggan on July 01, 2012, 05:54:38 AM
Title: Non-looping UISpriteAnimation
Post by: doggan on July 01, 2012, 05:54:38 AM
I purchased NGUI a few weeks ago, and I am extremely pleased! It is very well designed and easy to use. Thanks for the great library.
In addition to my UI and gameplay, I am using NGUI for all of my particle effects.
For example, an explosion effect has 5 frames of animation data. Using UISpriteAnimation, I can get the desired effect I want.
However, it was not perfect, so I made changes locally to the NGUI library in order to get the behavior I want. My question is: Is there a better way to do this? If not, is it possible to request this type of functionality for a future version of NGUI?
Here is what I added:
Ability to set a non-looping UISpriteAnimation (single-shot) - The explosion should play once and then stop.
Public interface to query for when the animation is done playing - When the explosion is done playing, some other code looks at the “IsDone” flag and destroys the particle effect. (This could also be done with SendMessage, but I opted with the flag for performance reasons).
Public interface for resetting the animation to the first frame - All of my particle effects are pooled, so when an explosion is destroyed, it is recycled and used later, so I need to reset the animation.
Is this the correct way to approach this, or is there a better way? If not, is it possible to request this functionality?
Thanks for reading!
Title: Re: Non-looping UISpriteAnimation
Post by: ArenMook on July 01, 2012, 11:19:33 AM
When designing this feature back in the day I skimmed over it thinking "meh, no one will want to use NGUI like it's 2D Toolkit"... I can ask Phil to take a look into adding these features next week (good suggestions btw!).
Title: Re: Non-looping UISpriteAnimation
Post by: doggan on July 02, 2012, 08:06:31 AM
Awesome! Thanks for the quick response.
Title: Re: Non-looping UISpriteAnimation
Post by: doggan on July 20, 2012, 07:03:44 AM
Thank you for adding this functionality to the 2.1.0 release. :D
However, I tried to use it and I think it is bugged.
In UISpriteAnimation.cs, this:
publicbool isDone {get{return mActive;}}
... should be this:
publicbool isDone {get{return!mActive;}}
Making this change, it seems to work perfectly.
(Or, the accessor should be renamed from "isDone" to "isPlaying" or "isActive").
Thanks!
Title: Re: Non-looping UISpriteAnimation
Post by: PhilipC on July 20, 2012, 09:49:44 AM