首页 > 代码库 > 为 iTween 指定特定的回调 : onupdate, oncomplete ...
为 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}
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。