Hi,
After tracking down some issues in our project these days, I think there are some problems with NGUI's tweening. Please correct me if I'm wrong.
1. UITweener calls an Update() immediately after Play() or Start() is called. This will make the current frame's deltaTime count in the total duration. When I call Play() or Start(), I'm actually expecting the tween to start exactly the time I call it, rather than some milliseconds before. Besides the inaccuracy in time control and visual flaws it caused, if the current frame is a quite long one while the tween duration is short, this could cause an even more critical problem: the tween will finish immediately, right after Play() or Start() is called, following by its onFinished callback. This leads to the second problem:
2. UIPlayTween iterates through all the tweens, find out those matching the specified tween group id, and do the following things to each of them: increase a zero-based counter by one, add an onFinished callback, and play it. In the onFinished callback, it then reduces the counter by one and see if it will become zero, which means all the tweens are finished playing, and it's time to invoke its own onFinished callback. All these worked perfectly except for one thing: if the first tween is rather short in duration, problem 1 could be triggered and the tween will finish instantly. Tween counter will be increased to 1 and reduced to 0 right away, then UIPlayTween's onFinished callback will be invoked - actually there are still many tweens not started yet. If the second tween is also very short, the procedure will repeat and the UIPlayTween's onFinished callback could be invoked multiple times, in one frame, leading to unexpected behaviors.
There is a simple solution to problem 2, we can split the iteration, count first, then play the tweens. This will ensure the onFinished callback to be invoked only once, however problem 1 is still the prime.
There is also a mechanism to prevent re-entrancy in UIPlayTween's OnFinished method. This mechanism is problematic with problem 1 if you want to chain up multiple UIPlayTweens. I guess it's no longer needed if problem 1 is resolved, too.
3. UIPlayTween tends to play a tween twice if resetOnPlay is set to true. It first plays the tween, then rewind it to the beginning, and play it again. I suspect there are special reasons to do so, however I can't figure it out. As with problem 1, the onFinished callback of the tween could be invoked twice in this circumstance.
Something weird is, these problems became quite significant after I updated my Unity to 5.2, from 5.0. They occurred sparsely and randomly in 5.0, caused some minor visual flaws so I didn't care about them (have a full list of more important things to do). However in 5.2, a great amount of short-time tweens disappeared from my app. I upgraded my NGUI to 3.9.4, too, not helpful.
Any idea would be appreciated.