Subscribe for onComplete event when having multiple tweens
« on: July 15, 2015, 02:05:59 PM »
Hi,

Already posted on the unity forums, but anyways.. I am using the DoTween Pro version. I want to have a panel that slides out from the left side of the window and after a couple of seconds slides back in using a different move algorithm. I have added two DoTweenAnimation scripts to the game object, set them up and named them with different ids - NotificationOut and NotificationIn. In my show function I first rewind and than play both tweens.

Quote
panel.gameObject.GetComponent<DOTweenAnimation> ().DORewind ();
panel.gameObject.GetComponent<DOTweenAnimation> ().DOPlayById ("NotificationOut"); 
 
yield return new WaitForSeconds(2.5f);
 
panel.gameObject.GetComponent<DOTweenAnimation> ().DOPlayById ("NotificationIn");

My questions are:
1. Is this the correct way to use the component when having multiple tweens attached to the same game object.
2. How can I subscribe for the onCompleted event of the second tween - NotificationIn.

Thanks in advance

Re: Subscribe for onComplete event when having multiple tweens
« Reply #1 on: July 16, 2015, 06:13:04 PM »
Try this:

- For NotificationOut component in the editor enable OnComplete and make a function with the same gameobject
- Under DOTweenAnimation function set, do a DoRestartByID, and set "NotificationIn" string as the value.  This is basically saying when the tween completes, callback will trigger the second tween
- In your NotificationIn tween, set delay to 2.5 to give it the pause you want before tweening starts

Re: Subscribe for onComplete event when having multiple tweens
« Reply #2 on: July 18, 2015, 09:07:15 PM »
Thank you, cynicalwanderer, that solved my issue.