public bool updateInternal()
{
float directionLocal = this.direction;
if(this.usesNormalDt){
dt = LeanTween.dtActual;
}else if( this.useEstimatedTime ){
dt = LeanTween.dtEstimated;
}else if( this.useFrames ){
dt = this.optional.initFrameCount==0 ? 0 : 1;
this.optional.initFrameCount = Time.frameCount;
}else if( this.useManualTime ){
dt = LeanTween.dtManual;
}
// Debug.Log ("tween:" + this+ " dt:"+dt);
if(this.delay<=0f && directionLocal!=0f){
if(trans==null)
return true;
// initialize if has not done so yet
if(!this.hasInitiliazed)
this.init();
dt = dt*directionLocal;
this.passed += dt;
this.ratioPassed = Mathf.Clamp01(this.passed / this.time); // need to clamp when finished so it will finish at the exact spot and not overshoot
this.easeInternal();
if(this.hasUpdateCallback)
this._optional.callOnUpdate(val, this.ratioPassed);
bool isTweenFinished = directionLocal>0f ? this.passed>=this.time : this.passed<=0f;
// Debug.Log("lt "+this+" dt:"+dt+" fin:"+isTweenFinished);
if(isTweenFinished){ // increment or flip tween
this.loopCount--;
if(this.loopType==LeanTweenType.pingPong){
this.direction = 0.0f-directionLocal;
}else{
this.passed = Mathf.Epsilon;
}
isTweenFinished = this.loopCount == 0 || this.loopType == LeanTweenType.once; // only return true if it is fully complete
if(isTweenFinished==false && this.onCompleteOnRepeat && this.hasExtraOnCompletes)
callOnCompletes(); // this only gets called if onCompleteOnRepeat is set to true, otherwise LeanTween class takes care of calling it
return isTweenFinished;
}
}else{
this.delay -= dt;
}
return false;
}