为 iTween 指定特定的回调 : onupdate, oncomplete

问题地址:Specifying a delegate for the value of onupdate in iTween

1、找到 void CallBack

2、修改以下代码:

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;
} //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 if (tweenArguments[callbackType] is Action) {
((Action)tweenArguments[callbackType]).Invoke();
}else if (tweenArguments[callbackType] is Action<object>) {
((Action<object>)tweenArguments[callbackType]).Invoke((object)tweenArguments[callbackType + "params"]);
}else{
Debug.LogError("iTween Error: Callback method references must be passed as a String!");
Destroy (this);
}
}
}

3、用法如下:

iTween.MoveTo(gameObject, iTween.Hash(
"x", x,
"y", y,
"time", t,
"easeType", iTween.EaseType.easeInCubic,
"oncomplete", (Action)Landing)); void Landing() {
// TODO
}
上一篇:使用Xamarin实现跨平台移动应用开发(转载)


下一篇:Linux系统开机默认开启无线网卡