iTween更改onupdate代理方法

	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);
			}
		}
	}

更改后可以尝试用代理的方式写方法 例如:

iTween.ValueTo(gameObject, iTween.Hash("from", 1,
                                       "to", 0,
                                       "speed", 1,
                                       "onupdate", (Action<object>)(newVal =>
                                       { hudStatusSlider.value = (float)newVal; })
                                       ));

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页