Exemple #1
0
 static public int clear(IntPtr l)
 {
     try {
         GoTweenConfig self = (GoTweenConfig)checkSelf(l);
         self.clear();
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #2
0
    private void initialize(object target, float duration, GoTweenConfig config, Action <AbstractGoTween> onComplete = null)
    {
        // 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.targetTransform = target as Transform;

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

        if (config.autoClear)
        {
            config.clear();
        }
    }