Support => NGUI 3 Support => Topic started by: Wisteso on May 15, 2014, 04:04:57 PM
Title: TweenAlpha's onFinished being called immediately, not after finished [Solved]
Post by: Wisteso on May 15, 2014, 04:04:57 PM
In my tests, I'm seeing my onFinished callback being called immediately (well 9 milliseconds later actually) after starting a tween.
It's very obvious in my tests since I have the following code...
publicvoid ButtonClicked(GameObject buttonObject)
{
NGUITools.SetActive(background, true, false);
Debug.Log("Before: "+System.DateTime.Now.Ticks);
backgroundTweener.PlayReverse();// backwards for some reason
}
Then a different button click calls...
backgroundTweener.PlayForward();
And once the tween is over, I want to disable the GameObject, so I registered the following function with the onFinished event of the Tweener...
publicvoid FadeCallback()
{
Debug.Log("After: "+System.DateTime.Now.Ticks);
NGUITools.SetActive(background, false, false);
}
However, only 90,000 ticks (9 ms) are passing even though the tween is 250 milliseconds (0.25 seconds). Everything works just fine with the SetActive calls removed, except that the GameObject is always active, of course. Everything seems to be hooked up correctly. You can clearly tell that the only issue is that the onFinished is firing immediately.
Title: Re: TweenAlpha's onFinished being called immediately, not after finished
Post by: Wisteso on May 15, 2014, 04:40:07 PM
Nope. This was programmer error.
For some reason I was thinking that onFinished would only be called at the end of my "fade out" tween. When obviously it gets callled at the end of both tweens.