Is there an easy way to modify iTween to be able to pass delegates as values for callbacks like onupdate?
Checking the source of the CallBack method in iTween.cs, I can see that anything that’s not a string is currently rejected for the value of something like onupdate:
/* From iTween.cs */
//throw an error if a string wasn't passed for callback:
if (tweenArguments[callbackType].GetType() == typeof(System.String)) {
target.SendMessage((string)tweenArguments[callbackType],(object)tweenArguments[callbackType+"params"],SendMessageOptions.DontRequireReceiver);
}else{
Debug.LogError("iTween Error: Callback method references must be passed as a String!");
Destroy (this);
}
Anyone know what would be the best way to achieve something that would be close to the following?
Modify the iTween.cs, changed the method Callback() at Line 7039 to
void CallBack(string callbackType){
if (tweenArguments.Contains(callbackType) && !tweenArguments.Contains("ischild")) {
//establish target:
GameObject target;
if (tweenArguments.Contains(callbackType+"target")) {
target=(GameObject)tweenArguments[callbackType+"target"];
}else{
target=gameObject;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (tweenArguments[callbackType] is Action<object>) {
((Action<object>)tweenArguments[callbackType]).Invoke((object)tweenArguments[callbackType + "params"]);
} else
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//throw an error if a string wasn't passed for callback:
if (tweenArguments[callbackType].GetType() == typeof(System.String)) {
target.SendMessage((string)tweenArguments[callbackType],(object)tweenArguments[callbackType+"params"],SendMessageOptions.DontRequireReceiver);
}else{
Debug.LogError("iTween Error: Callback method references must be passed as a String!");
Destroy (this);
}
}
}