- Home /
iTween oncomplete method on normal C# class
I have a normal C# class (non MonoBehaviour class) which I have been using iTween to animate some UI elements in my scene. Can I set the 'oncomplete' method to be in that class or does it only work when I pass a gameObject for 'oncompletetarget' field. Basically, is there a way to make the 'oncompletetarget' points to something other than a game object.
Any suggestion is highly appreciated!
Answer by Nischo · Jul 07, 2015 at 04:44 PM
No not directly. I'm pretty sure iTween uses SendMessage to broadcast these events to GameObjects. But you can always have an empty GameObject with a "proxy" script in your scene. As long as that script/object has access to your "non-gameobject" class it works. A Singleton GameObject comes to my mind as quick (but a bit messy) solution.
Thanks for the quick reply. But I don't want to use what you suggested as it will yield to a messy codebase and I want to keep it clean as possible. I've haven't found a answer to the question I posted. But I've found an overall better solution to my problem. I've abandoned iTween and started using LeanTween. https://www.assetstore.unity3d.com/en/#!/content/3595. It's very very good and supports callbacks to non mono behaviour classes. This does everything that I want from iTween but better and faster (more performant). http://dentedpixel.com/LeanTweenDocumentation/classes/LeanTween.html. Oh and did I forget to mention that it's free as well. :)