- Home /
iTween multiple GUI elements with one callback
I'm using iTween.ValueTo to manipulate the buttons and other GUI objects I want to move. However, at the moment I have a seperate callback function for each one because it only takes one argument (the new value). For example:
iTween.ValueTo(gameObject, {"from":startBtn, "to":Rect(50,300,100,100), "time":.5, "onUpdate":"UpdateStartButton"});
function UpdateStartButton(pos:Rect) { startBtn = pos; }
This may be a bad way of doing it, please correct me if so. The problem with this method is I have many objects I want to move, and each one seems to need it's own function to callback and change the value.
I assume that using the hashtable it is possible to make the callback function take an additional argument (say, a Rect to update to) thereby making it possible to use one generic callback for all my ValueTo lines. However, I have no been able to find the correct syntax to do this.
Answer by pixelplacement · Nov 03, 2010 at 12:31 AM
Hey Alex,
Unfortunately that's the way it goes right now for ValueTo(). I'll admit it's a tad rough and cumbersome. I have a TON of things going on right now but I'll spare a few brain clicks here and there on looking into solving this better. I'm also hoping to get working on iTween 3.0 in a few months.
I wonder if you can somehow leverage the OnStart callback somehow with some trickery... ?
Good luck!
You're just a great guy, pixelplacement. Thanks for all the effort you put into iTween
Your answer
![](https://koobas.hobune.stream/wayback/20220613081416im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Stuck with sliding GUI panels 0 Answers
move a gui element 1 Answer
using iTween.ValueTo for the rotation of a GameObject with RotateAround 1 Answer