Author Topic: UITweener now clears OnFinished delegate list when calling Begin()  (Read 235 times)

titan_artix

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Hey guys,

Just updated to 3.11.1 yesterday and released this morning that the NGUI update is causing some issues related to callbacks in our project.  We first noticed the problem when a callback event wasn't firing properly.  After diagnosing for a bit, we released that UITweener Begin() now clears the OnFinished delegate list on line 486:

  1. comp.onFinished.Clear();

This line isn't make much sense to us as it instantly breaks all of our callbacks where we've defined the OnFinished callback in the Unity Editor.  An example is with the TweenColor component as shown in the pictures below.  Everything looks fine in the editor, but at run time the reference is cleared just before usage. Commenting out line 486 fixes everything for us, but we don't love that option and want to better understand the intention here.


titan_artix

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UITweener now clears OnFinished delegate list when calling Begin()
« Reply #1 on: February 16, 2017, 10:23:59 AM »
Apologies for the typos in my first post. It seems there is no edit post functionality. 

I just wanted to add clarity to the issue. In our previous build, we used NGUI (v3.10.2) and had no issues. Since upgrading to NGUI v3.11.1, we noticed that the callbacks for several Tween-based events simply are not firing in our game. Anything previously reliant upon the UITweener OnFinished callback no longer fires because the OnFinished list is cleared immediately within Begin(). 

We can easily fix the issue by commenting out the lines that call Clear(), but we don't understand why that was added?  It seems your intention was to clear any one-time only callback events, but since our intention is to use these as permanent callbacks that should fire everytime a tween completes things are breaking.

Can you shed some light on what we're doing wrong?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 297
  • -Receive: 1136
  • Posts: 21,937
  • Toronto, Canada
    • View Profile
Re: UITweener now clears OnFinished delegate list when calling Begin()
« Reply #2 on: February 18, 2017, 07:07:48 PM »
The change was intentional to avoid old callbacks from sticking around. This only affects code-triggered execution that called Tween.Begin directly though -- implying you'd be setting your delegates via code as well so it shouldn't affect you. Why are your delegates already present prior to calling the Begin? What's your setup?

titan_artix

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UITweener now clears OnFinished delegate list when calling Begin()
« Reply #3 on: February 20, 2017, 01:47:04 PM »
Thanks for the response. In our project, the OnFinished callback is often used within the Unity Editor to define permanent methods that handle the completion of Tweens (color, alpha, etc). An example of this use case is shown in the attached image where we perform some simple actions after our cast bar animation completes. Our intention is for this callback to remain permanently as the cast bar animation can be played and completed multiple times during a user session. 

In code, we generally call something like this to start the animation:
  1. TweenColor.Begin(bg.gameObject, 0.3f, InterfaceColors.CastBar.Interrupt);

We then rely on the permanent editor defined callback to complete our logic loop. Now with the 3.11.1 update, since the OnFinished list is cleared when calling Begin(), the callback logic never fires.

Sorry if I'm missing something basic here (I recently joined this team and I'm a bit of an NGUI novice; my previous project used Unity's native GUI). Any help here would be useful.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 297
  • -Receive: 1136
  • Posts: 21,937
  • Toronto, Canada
    • View Profile
Re: UITweener now clears OnFinished delegate list when calling Begin()
« Reply #4 on: February 21, 2017, 12:43:59 PM »
TweenColor.Begin effectively starts a new tween animation. In your case you already have one, so you should be simply using a GetComponent<TweenColor>() and calling PlayForward() on it.