GoTween.goTo C# (CSharp) Method

goTo() public method

goes to the specified time clamping it from 0 to the total duration of the tween. if the tween is not playing it will be force updated to the time specified.
public goTo ( float time, bool skipDelay ) : void
time float
skipDelay bool
return void
    public override void goTo( float time , bool skipDelay)
    {
        // handle delay, which is specific to Tweens
        if( skipDelay )
        {
            _elapsedDelay = delay;
        }
        else
        {
            _elapsedDelay = Mathf.Min( time, delay );
            time -= _elapsedDelay;
        }

        _delayComplete = _elapsedDelay >= delay;

        time = Mathf.Clamp( time, 0f, totalDuration );

        // provide an early out for calling goto on the same time multiple times.
        if ( time == _totalElapsedTime )
            return;

        // if we are doing a goTo at the "start" of the timeline, based on the isReversed variable,
        // allow the onBegin and onIterationStart callback to fire again.
        // we only allow the onIterationStart event callback to fire at the start of the timeline,
        // as doing a goTo(x) where x % duration == 0 will trigger the onIterationEnd before we
        // go to the start.
        if ( ( isReversed && time == totalDuration ) || ( !isReversed && time == 0f ) )
        {
            _didBegin = false;
            _fireIterationStart = true;
        }
        else
        {
            _didBegin = true;
            _fireIterationStart = false;
        }

        // since we're doing a goTo, we want to stop this tween from remembering that it iterated.
        // this could cause issues if you caused the tween to complete an iteration and then goTo somewhere
        // else while still paused.
        _didIterateThisFrame = false;

        // force a time and completedIterations before we update
        _totalElapsedTime = time;
        _completedIterations = isReversed ? Mathf.CeilToInt( _totalElapsedTime / duration ) : Mathf.FloorToInt( _totalElapsedTime / duration );

        update( 0 );
    }

Usage Example

Esempio n. 1
0
    void Start()
    {
        if ( Path != null )
        {
            tween = Path.GetComponent<PointPath> ().Animate ( gameObject, Duration, Ease, LoopInfinitely, IsRelative );

            if ( StartTime != 0 )
                tween.goTo ( StartTime );
        }
    }
All Usage Examples Of GoTween::goTo