So I'm using iTween moveTo() function in C# and trying to get the onComplete paramter to call my defined function when the iTween is complete. So I have: iTween.moveTo(selectedObj, 1, 0, pos, null, "OnMoveComplete", ""); Then in my class I have: void OnMoveComplete(object obj) { Debug.Log("Testing"); } I never see "Testing" in the console. What am I doing wrong?
I plan on putting together even better documentation with the release of iTween 2.0 to address questions such as this but let me explain what's going on in your situation. iTween is being attached to 'selectedObj' and therefore is attempting to call 'OnMoveComplete' on that object. To solve this, also pass in 'onCompleteTarget' and give it a refrence to this GameObject. Cool?
Ah, very cool! I created a script in the target object that would route the call back to my main script, but this will be much better. Thanks!! Keep up the good work.
Can someone please give me example call for that? In my case i wrote that: Code (csharp): iTween.moveTo(obj, 1f, null, new Vector3(obj.transform.position.x, -1.5f, obj.transform.position.z), iTween.EasingType.linear, "OnComplete", null, obj, obj); But it doens´t work. I don´t know which reference you mean. Any help on that? Thanks a lot
The way you have written it it will call OnComplete on the object 'obj' If you want it to call it on this gameobject, you need to replace , null, obj with , this, obj for example
Hi, I have some troubles with the callback function. What can I do if the script in which I use iTween is not attached to the gameobject I move (in fact the callfunction is not on a script attached to any gameObject)? I want to modify a boolean if the movment is finished (the change occurs in the callback function) but this boolean and the callback function are in the script that is not linked to any gameobject (it's a camera mod script which is instancied by a camara mod's manager)
iTween can only call a function that is attached to a GO. You can target any GO you want - is there any chance you can just make a helper call to this script you need? Maybe another static method that could be called somehow?
Ok thanks, it should work (but I don't like to use too many static functions/variables that should be private and localised only in the class linked to it the logical way).