public override bool update( float deltaTime )
{
// properties are prepared only once on the first update of the tween.
if ( !_didInit )
onInit();
// should we validate the target?
if( Go.validateTargetObjectsEachTick )
{
// This might seem to be overkill, but on the case of Transforms that
// have been destroyed, target == null will return false, whereas
// target.Equals(null) will return true. Otherwise we don't really
// get the benefits of the nanny.
if( target == null || target.Equals(null) )
{
// if the target doesn't pass validation
Debug.LogWarning( "target validation failed. destroying the tween to avoid errors. Target type: " + this.targetType );
autoRemoveOnComplete = true;
return true;
}
}
// we only fire the begin callback once per run.
if ( !_didBegin )
onBegin();
// handle delay and return if we are still delaying
if( !_delayComplete && _elapsedDelay < delay )
{
// if we have a timeScale set we need to remove its influence so that delays are always in seconds
if( timeScale != 0 )
_elapsedDelay += deltaTime / timeScale;
// are we done delaying?
if( _elapsedDelay >= delay )
_delayComplete = true;
return false;
}
// loops only start once the delay has completed.
if ( _fireIterationStart )
onIterationStart();
// base will calculate the proper elapsedTime, iterations, etc.
base.update( deltaTime );
// if we are looping back on a PingPong loop
var convertedElapsedTime = _isLoopingBackOnPingPong ? duration - _elapsedTime : _elapsedTime;
//Debug.Log(string.Format("{0} : {1} -- {2}", _elapsedTime, convertedElapsedTime, _isLoopingBackOnPingPong ? "Y" : "N"));
// update all properties
for( var i = 0; i < _tweenPropertyList.Count; ++i )
_tweenPropertyList[i].tick( convertedElapsedTime );
onUpdate();
if ( _fireIterationEnd )
onIterationEnd();
if( state == GoTweenState.Complete )
{
onComplete();
return true; // true if complete
}
return false; // false if not complete
}