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!

« Last Edit: March 01, 2016, 09:30:28 PM by princemoonrise »

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: OnComplete callback from Instantiated object using DOTween Path?
« Reply #1 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 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();

Re: OnComplete callback from Instantiated object using DOTween Path?
« Reply #2 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!

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: OnComplete callback from Instantiated object using DOTween Path?
« Reply #3 on: March 02, 2016, 02:57:52 PM »
Thanks to you for the compliments :)