Demigiant Forum

Unity Assets => DOTween & DOTween Pro => Topic started by: princemoonrise on March 01, 2016, 05:57:14 PM

Title: OnComplete callback from Instantiated object using DOTween Path?
Post by: princemoonrise on March 01, 2016, 05:57:14 PM
I am trying to do a callback from OnComplete, when using a DOTween Path.  While I was able to get it working by using the OnComplete tab from the inspector and placing the prefab in the object select box, I also wanted to be able to call it from code.

I was able to get the path to activate by using DOPlay, but it seems I cannot get the syntax right for the callback (I am very new to C#/Unity so please bear with me!);  could someone suggest the proper syntax for this?:
Code: [Select]
GetComponent<DOTweenPath>().DOPlay().OnComplete(MyCallback);
Thank you for your help!

Title: Re: OnComplete callback from Instantiated object using DOTween Path?
Post by: Daniele on March 02, 2016, 12:04:48 PM
Hi,

If you want to use more advanced runtime features on your DOTweenPath, you have to grab the tween from it (created at the first Awake call), and after that you can use the full DOTween API (http://dotween.demigiant.com/documentation.php) on your tween. That is done by using myDOTweenPath.GetTween(). So your code should look like this:

Code: [Select]
Tweent t = GetComponent<DOTweenPath>().GetTween();
t.OnComplete(myCallback);
t.Play();
Title: Re: OnComplete callback from Instantiated object using DOTween Path?
Post by: princemoonrise on March 02, 2016, 01:28:09 PM
Thank you so much, the code worked perfectly!  I did try declaring the tween first but didn't think to try to play the tween as the last step.

DOTween is amazing, and I've already been able to use it for many purposes.  I have another problem I need answered but I will post a new topic to keep the forum organized.  Thank you again for the help and your amazing asset!
Title: Re: OnComplete callback from Instantiated object using DOTween Path?
Post by: Daniele on March 02, 2016, 02:57:52 PM
Thanks to you for the compliments :)