GoTween.GoTween C# (CSharp) 메소드

GoTween() 공개 메소드

initializes a new instance and sets up the details according to the config parameter
public GoTween ( object target, float duration, GoTweenConfig, config, Action onComplete = null ) : System
target object
duration float
config GoTweenConfig,
onComplete Action
리턴 System
    public GoTween( object target, float duration, GoTweenConfig config, Action<AbstractGoTween> onComplete = null )
    {
        // all tweens must be intialized to have a duration greater than zero. keep in mind that this will ensure
        // the tween occurs over two frames: the initialized value, and the final value. if you are looking for a
        // tween to reach the end of it's tween immediately, be sure to call complete() on it after creation.
        if( duration <= 0 )
        {
            duration = float.Epsilon;
            Debug.LogError( "tween duration must be greater than 0. coerced to float.Epsilon." );
        }

        // default to removing on complete
        autoRemoveOnComplete = true;

        // allow events by default
        allowEvents = true;

        // setup callback bools
        _didInit = false;
        _didBegin = false;

        // flag the onIterationStart event to fire.
        // as long as goTo is not called on this tween, the onIterationStart event will fire
        // as soon as the delay, if any, is completed.
        _fireIterationStart = true;

        this.target = target;
        this.targetType = target.GetType();
        this.duration = duration;

        // copy the TweenConfig info over
        id = config.id;
        delay = config.delay;
        loopType = config.loopType;
        iterations = config.iterations;
        _easeType = config.easeType;
        easeCurve = config.easeCurve;
        updateType = config.propertyUpdateType;
        isFrom = config.isFrom;
        timeScale = config.timeScale;

        _onInit = config.onInitHandler;
        _onBegin = config.onBeginHandler;
        _onIterationStart = config.onIterationStartHandler;
        _onUpdate = config.onUpdateHandler;
        _onIterationEnd = config.onIterationEndHandler;
        _onComplete = config.onCompleteHandler;

        if( config.isPaused )
            state = GoTweenState.Paused;

        // if onComplete is passed to the constructor it wins. it is left as the final param to allow an inline Action to be
        // set and maintain clean code (Actions always try to be the last param of a method)
        if( onComplete != null )
            _onComplete = onComplete;

        // add all our properties
        for( var i = 0; i < config.tweenProperties.Count; ++i )
        {
            var tweenProp = config.tweenProperties[i];

            // if the tween property is initialized already it means it is being reused so we need to clone it
            if( tweenProp.isInitialized )
                tweenProp = tweenProp.clone();

            addTweenProperty( tweenProp );
        }

        // calculate total duration
        if( iterations < 0 )
            totalDuration = float.PositiveInfinity;
        else
            totalDuration = iterations * duration;
    }