iTween oncompleteparams in C#

I’ve been looking for an example of passing multiple parameters to the oncomplete function and can’t find any (even purchased the callbacks example on the iTween site). Can someone post a working example of creating and passing multiple arguments to a callback function in iTween (or point me to a thread that addresses this)? Note that it works fine for passing a single argument, but I need to pass several arguments of different types. Also, are there any issue I need to address on the target procedure to accept the passed parameters (it accepts a string and color)?

Rick

Another sort of related question about oncomplete - is it possible to have the oncomplete target execute after a stop is issued?

Rick

I need to use the oncompleteparams parameter with multiple params. I have been doing some research in multiple sites and this is my example. The function does a MoveTo and returns to the previous position just once (not like PingPong):

///


/// MoveToPingPongOnce. Begin position is current position of GameObject. Will move to endPosition and return to Begin Position
///

/// GameObject which applies movement. Begin position is current position.
/// End Position
/// Time in seconds
/// GameObject target for oncomplete function
/// Function to call oncomplete
/// Relative to parent (false) or worldcoordinates (true)
public void MoveToPingPongOnce(GameObject g, Vector3 endPosition, float time, bool islocal = true) {
Hashtable param = new Hashtable();

param.Add(“GameObject”, g);
param.Add(“endPosition”, new Vector3(g.transform.position.x, g.transform.position.y, g.transform.position.z));
param.Add(“time”, time);
param.Add(“islocal”, islocal);

iTween.MoveTo(g, iTween.Hash(“position”, endPosition, “time”, time, “islocal”, islocal, “oncomplete”, “endMoveToPingPongOnce”, “oncompletetarget”, this.gameObject, “oncompleteparams”, param));
}

void endMoveToPingPongOnce(object ht) {
Hashtable param = (Hashtable)ht;

iTween.MoveTo((GameObject)param[“GameObject”], iTween.Hash(“position”, (Vector3)param[“endPosition”], “time”, (float)param[“time”], “islocal”, (bool)param[“islocal”]));
}

1 Like