setLoopPingPong() public méthode

public setLoopPingPong ( ) : LTDescr
Résultat LTDescr
Exemple #1
0
        //IEnumerator HandleTweenDelayed()
        //{
        //    float counter = 0;
        //    while (counter < delay)
        //    {
        //        counter += Time.deltaTime;
        //        yield return null;
        //    }
        //    HandleTween();
        //}

        //IEnumerator Activate()
        //{
        //    float counter = 0;
        //    while (counter < delay)
        //    {
        //        counter += Time.deltaTime;
        //        yield return null;
        //    }
        //    objectToAnimate.SetActive(true);
        //}

        public void HandleTween()
        {
            if (objectToAnimate == null)
            {
                objectToAnimate = gameObject;
            }

            switch (animationType)
            {
            case UIAnimationType.Fade:
                Fade();
                break;

            case UIAnimationType.Move:
                Move();
                break;

            case UIAnimationType.MoveAbsolute:
                MoveAbsolute();
                break;

            case UIAnimationType.Scale:
                Scale();
                break;

            case UIAnimationType.ScaleX:
                ScaleX();
                break;

            case UIAnimationType.ScaleY:
                ScaleY();
                break;

            default:
                break;
            }

            _tweenObject.setDelay(delay);
            _tweenObject.setEase(easeType);

            if (loop)
            {
                _tweenObject.loopCount = int.MaxValue;
            }
            if (pingpong)
            {
                _tweenObject.setLoopPingPong();
            }
        }
Exemple #2
0
    private void Animate()
    {
        switch (animationType)
        {
        case UIAnimationTypes.Fade:
            tweenObject = Fade();
            break;

        case UIAnimationTypes.Move:
            tweenObject = Move();
            break;

        case UIAnimationTypes.Scale:
            tweenObject = Scale();
            break;
        }

        tweenObject.setDelay(delay);
        tweenObject.setEase(easeType);

        if (loop)
        {
            tweenObject.setLoopClamp();
        }
        if (pingpong)
        {
            tweenObject.setLoopPingPong();
        }
    }
Exemple #3
0
        void Start()
        {
            LTDescr ltDescr = LeanTween.moveLocalY(enterImage.gameObject, enterImage.transform.localPosition.y - 20f, 0.5f);

            ltDescr.setIgnoreTimeScale(true);
            ltDescr.setLoopPingPong();
            ltDescr.setRepeat(-1);
        }
    public void Execute()
    {
        switch (tweenType)
        {
        case TweenType.Move:
        {
            descr = LeanTween.move(gameObject, to, duration);
        }
        break;

        case TweenType.MoveX:
        {
            descr = LeanTween.moveX(gameObject, toX, duration);
        }
        break;

        case TweenType.MoveY:
        {
            descr = LeanTween.moveY(gameObject, toY, duration);
        }
        break;

        case TweenType.Scale:
        {
            descr = LeanTween.scale(gameObject, to, duration);
        }
        break;

        case TweenType.ScaleX:
        {
            descr = LeanTween.scaleX(gameObject, toX, duration);
        }
        break;

        case TweenType.ScaleY:
        {
            descr = LeanTween.scaleY(gameObject, toY, duration);
        }
        break;

        case TweenType.Rotate:
        {
            descr = LeanTween.rotate(gameObject, new Vector3(0, 0, rotation), duration);
        }
        break;
        }

        descr.setDelay(delay).setEase(easeType);
        if (loop)
        {
            descr.loopCount = int.MaxValue;
        }
        if (pingpong)
        {
            descr.setLoopPingPong();
        }
    }
Exemple #5
0
 private void PlayHurtEffect()
 {
     if (WorldBossProxy.instance.IsOpen)
     {
         LTDescr ltDescr = LeanTween.value(gameObject, Color.white, Color.red, 0.1f);
         ltDescr.setOnUpdate(OnUpdateBossHPBarColor);
         ltDescr.setRepeat(4);
         ltDescr.setLoopPingPong();
     }
     LeanTween.delayedCall(gameObject, 1, PlayHurtEffect);
 }
Exemple #6
0
        /// <summary>
        /// Animates a value from one value to another.
        /// </summary>
        /// <param name="data">The tween data.</param>
        /// <returns>The started tween reference.</returns>
        public Tween StartValueTo(ValueToAnimation data)
        {
            LeanTweenType easeType = this.tweenTypeDictionary[data.EaseType];
            LTDescr       item     = LeanTween.value(data.GameObject, data.OnUpdate, 0f, 1f, data.Duration).setDelay(data.Delay).setEase(easeType).setOnComplete(data.OnComplete).setUseEstimatedTime(true);

            if (data.PingPongLoop)
            {
                item.setLoopPingPong();
            }

            return(new Tween(item));
        }
Exemple #7
0
 private LTDescr ApplySettingsToTween(LTDescr tween)
 {
     if (_data.useCurve)
     {
         tween.setEase(_data.curve);
     }
     if (_loopPingPong)
     {
         tween.setLoopPingPong();
     }
     return(tween);
 }
Exemple #8
0
    public void Init()
    {
        //   Debug.Log("Initializing " + target.gameObject.name + "\n");
        if (target == null)
        {
            Debug.Log("Missing target for " + this.gameObject.name + " LeanTweener\n"); return;
        }
        LTDescr l = null;

        LeanTween.cancel(target);
        switch (type)
        {
        case TweenType.Scale:
            target.transform.localScale = init_vector;
            l = LeanTween.scale(target, vector, time).setIgnoreTimeScale(ignoreTimeScale);
            break;

        case TweenType.Rotate:
            l = LeanTween.rotateZ(target, value, time).setIgnoreTimeScale(ignoreTimeScale);
            break;

        case TweenType.ColorChange:
            l = LeanTween.color(target, my_color, time).setIgnoreTimeScale(ignoreTimeScale);
            break;

        default:
            return;
        }

        tweening = true;
        if (delay > 0)
        {
            l.setDelay(delay);
        }
        if (leantweentype != LeanTweenType.notUsed)
        {
            l.setEase(leantweentype);
        }
        if (pingpong > -99)
        {
            l.setLoopPingPong(pingpong);
        }



        if (duration != -99)
        {
            StartCoroutine(StopMeSoon());
        }
    }
Exemple #9
0
    public void Show()
    {
        rect        = GetComponent <RectTransform>();
        canvasGroup = GetComponent <CanvasGroup>();
        if (objectToAnimate == null)
        {
            objectToAnimate = gameObject;
        }
        switch (transitionType)
        {
        case UITransitionType.Move:
            Move();
            break;

        case UITransitionType.Scale:
            Scale();
            break;

        case UITransitionType.Fade:
            Fade();
            break;
        }

        tweenObject.setDelay(delay);
        tweenObject.setEase(easeType);
        tweenObject.setIgnoreTimeScale(true);

        if (loop)
        {
            tweenObject.loopCount = int.MaxValue;
        }

        if (pingpong)
        {
            tweenObject.setLoopPingPong();
        }
    }
        // Code that runs on entering the state.
        public override void OnEnter()
        {
            var len = pathPoints.Length;

            Vector3[] tweenVector = new Vector3[len];

            for (var i = 0; i < len; i++)
            {
                tweenVector [i] = pathPoints [i].Value;
            }

            GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);

            Fsm.Event(onStartEvent);

            LTDescr tween = LeanTween.move(go, tweenVector, time.Value);

            LeanTweenID.Value = tween.id;

            tween.setOrientToPath(orientToPath.Value);
            tween.setAxis(axis.Value);
            tween.setEase(easeType);
            tween.setDelay(delay.Value);

            if (noOfRepeat.Value > 0)
            {
                tween.setRepeat(noOfRepeat.Value);
            }

            switch (LoopType)
            {
            case LTLoop.clamp:
                tween.setLoopClamp();
                break;

            case LTLoop.once:
                tween.setLoopOnce();
                break;

            case LTLoop.pingpong:
                tween.setLoopPingPong();
                break;
            }

            tween.setOnComplete(doOnComplete);
            tween.setOnUpdate(doOnUpdate);
            tween.setUseEstimatedTime(useEstimatedTime.Value);
            tween.setUseFrames(useFrames.Value);
        }
Exemple #11
0
        public void Run()
        {
            if (playType == PlayType.Cycle)
            {
                playingAnim = LeanTween.moveSpline(gameObject, animPath, time)
                              .setOrientToPath(!staticOrientation)
                              .setLoopClamp();
            }
            else
            {
                playingAnim = LeanTween.moveSpline(gameObject, animPath, time)
                              //.setEase(LeanTweenType.easeOutQuad) // No easing until I sync animation
                              .setOrientToPath(!staticOrientation)
                              .setOnComplete(() =>
                {
                    if (OnComplete != null)
                    {
                        OnComplete();
                    }
                    OnMoveComplete();
                    if (ueOnComplete != null)
                    {
                        ueOnComplete.Invoke();
                    }
                });

                if (playType == PlayType.Repeat)
                {
                    playingAnim.setRepeat(repeats);
                }
                else if (playType == PlayType.PingPong)
                {
                    playingAnim.setLoopPingPong();
                }
            }

            if (animationCycler)
            {
                animationCycler[startAnimName].speed    = startAnimSpeed;
                animationCycler[startAnimName].wrapMode = startWrapMode;
                animationCycler.clip = animationCycler[startAnimName].clip;
                animationCycler.Play();
                if (moveSoundPlayer && moveSound)
                {
                    moveSoundPlayer.clip = moveSound;
                    moveSoundPlayer.Play();
                }
            }
        }
Exemple #12
0
        // Code that runs on entering the state.
        public override void OnEnter()
        {
            GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);

            GameObject tGo = targetGameObject.Value;

            if (tGo != null)
            {
                tempVector = tGo.transform.position;
            }
            else
            {
                tempVector = vector.Value;
            }
            Fsm.Event(onStartEvent);

            LTDescr tween = LeanTween.move(go, tempVector, time.Value);

            LeanTweenID.Value = tween.id;

            tween.setEase(easeType);
            tween.setDelay(delay.Value);

            if (noOfRepeat.Value > 0)
            {
                tween.setRepeat(noOfRepeat.Value);
            }

            switch (LoopType)
            {
            case LTLoop.clamp:
                tween.setLoopClamp();
                break;

            case LTLoop.once:
                tween.setLoopOnce();
                break;

            case LTLoop.pingpong:
                tween.setLoopPingPong();
                break;
            }

            tween.setOnComplete(doOnComplete);
            tween.setOnUpdate(doOnUpdate);
            tween.setUseEstimatedTime(useEstimatedTime.Value);
            tween.setUseFrames(useFrames.Value);
        }
Exemple #13
0
    void Start()
    {
        float to       = 0f;
        float duration = 2f;

        // animating alpha to make a dissolve effect of the image.
        LTDescr descAlpha = LeanTween.alpha(this.gameObject, to, duration);

        descAlpha.setEase(LeanTweenType.linear);
        descAlpha.setLoopPingPong();

        if (doRotate)
        {
            LTDescr descRot = LeanTween.rotate(this.gameObject, new Vector3(180f, 30f, 90f), rotDuration);
            descRot.setLoopPingPong();
        }
    }
Exemple #14
0
    public void HandleTween()
    {
        if (ObjectToAnimate == null)
        {
            ObjectToAnimate = gameObject;
        }

        switch (AnimationType)
        {
        case UIAnimationTypes.Fade:
            Fade();
            break;

        case UIAnimationTypes.Move:
            MoveAbsolute();
            break;

        case UIAnimationTypes.Scale:
            Scale();
            break;

        case UIAnimationTypes.ScaleX:
            Scale();
            break;

        case UIAnimationTypes.ScaleY:
            Scale();
            break;
        }

        _tweenObject.setDelay(Delay);
        _tweenObject.setEase(EaseType);

        if (Loop)
        {
            _tweenObject.loopCount = int.MaxValue;
        }

        if (PingPong)
        {
            _tweenObject.setLoopPingPong();
        }
    }
    public void HandleTween()
    {
        if (_objectToAnimate == null)
        {
            _objectToAnimate = gameObject;
        }

        switch (animationType)
        {
        case AnimationType.MOVE:
            MoveAbsolute();
            break;

        case AnimationType.SCALE:
            Scale();
            break;

        case AnimationType.SCALEX:
            Scale();
            break;

        case AnimationType.SCALEY:
            Scale();
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }

        _tweenObject.setDelay(delay);
        _tweenObject.setEase(easeType);

        if (loop)
        {
            _tweenObject.loopCount = int.MaxValue;
        }

        if (pingpong)
        {
            _tweenObject.setLoopPingPong();
        }
    }
Exemple #16
0
        private void MoveAnim(Vector3 position, bool againstWall)
        {
            float distancePercentage = againstWall ? wallBounceDistance : 1;

            Vector3 positionDiff = new Vector3(transform.position.x - position.x, transform.position.y - position.y);

            positionDiff = positionDiff * distancePercentage;

            LTDescr moveLTDescr = LeanTween.move(againstWall ? characterBody : gameObject, transform.position - positionDiff, moveTime).setEaseLinear();

            if (againstWall)
            {
                moveLTDescr.setTime(wallBounceTime);
                moveLTDescr.setLoopPingPong(1).setOnComplete(() => IsSafe = true);
            }
            else
            {
                moveLTDescr.setOnComplete(() => CheckCurrentTile());
            }
        }
Exemple #17
0
    private void SetTweenSettings()
    {
        if (!LeanTween.isTweening(id))
        {
            return;
        }

        LTDescr descr = LeanTween.descr(id);

        if (descr == null)
        {
            return;
        }

        if (easeType == LeanTweenType.animationCurve)
        {
            descr.setEase(animationCurve);
        }
        else
        {
            descr.setEase(easeType);
        }

        descr.setDelay(delay);

        if (loop)
        {
            if (pingPong)
            {
                descr.setLoopPingPong(loopTimes);
            }
            else
            {
                descr.setLoopClamp(loopTimes);
            }
        }

        descr.setOnComplete(() => onCompleteCallback?.Invoke());
        descr.setDestroyOnComplete(destroyOnComplete);
    }
Exemple #18
0
        // Code that runs on entering the state.
        public override void OnEnter()
        {
            GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);

            Vector3 final = go.transform.localPosition + vector.Value;

            Fsm.Event(onStartEvent);

            LTDescr tween = LeanTween.moveLocal(go, final, time.Value);

            LeanTweenID.Value = tween.id;

            tween.setEase(easeType);
            tween.setDelay(delay.Value);

            if (noOfRepeat.Value > 0)
            {
                tween.setRepeat(noOfRepeat.Value);
            }

            switch (LoopType)
            {
            case LTLoop.clamp:
                tween.setLoopClamp();
                break;

            case LTLoop.once:
                tween.setLoopOnce();
                break;

            case LTLoop.pingpong:
                tween.setLoopPingPong();
                break;
            }

            tween.setOnComplete(doOnComplete);
            tween.setOnUpdate(doOnUpdate);
            tween.setUseEstimatedTime(useEstimatedTime.Value);
            tween.setUseFrames(useFrames.Value);
        }
Exemple #19
0
    public void Show()
    {
        if (_target == null)
        {
            _target = gameObject;
        }

        switch (_animationType)
        {
        case UIAnimayionTypes.Move:
            Move();
            break;

        case UIAnimayionTypes.Scale:
            Scale();
            break;

        case UIAnimayionTypes.Rotate:
            Rotate();
            break;

        case UIAnimayionTypes.Fade:
            Fade();
            break;
        }

        _tweenObj.setDelay(_delay);
        _tweenObj.setEase(_easeType);

        if (_loop)
        {
            _tweenObj.setLoopCount(-1);
        }
        if (_pingPong)
        {
            _tweenObj.setLoopPingPong();
        }
        _tweenObj.setOnComplete(() => _onComplete?.Invoke());
    }
        // Code that runs on entering the state.
        public override void OnEnter()
        {
            GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);

            float final = go.transform.eulerAngles.x + degrees.Value;

            Fsm.Event(onStartEvent);

            LTDescr tween = LeanTween.rotate(go.GetComponent <RectTransform>(), final, time.Value);

            LeanTweenID.Value = tween.id;

            tween.setEase(easeType);
            tween.setDelay(delay.Value);

            if (noOfRepeat.Value > 0)
            {
                tween.setRepeat(noOfRepeat.Value);
            }

            switch (LoopType)
            {
            case LTLoop.clamp:
                tween.setLoopClamp();
                break;

            case LTLoop.once:
                tween.setLoopOnce();
                break;

            case LTLoop.pingpong:
                tween.setLoopPingPong();
                break;
            }

            tween.setOnComplete(doOnComplete);
            tween.setUseEstimatedTime(useEstimatedTime.Value);
            tween.setUseFrames(useFrames.Value);
        }
    private void HandleTween()
    {
        if (objectToAnimate == null)
        {
            objectToAnimate = gameObject;
        }

        switch (animationType)
        {
        case UIAnimationType.Move:
            Move();
            break;

        case UIAnimationType.Rotate:
            Rotate();
            break;

        case UIAnimationType.Scale:
            Scale();
            break;

        case UIAnimationType.Fade:
            Fade();
            break;
        }

        tweenObject.setDelay(delay);
        tweenObject.setEase(easeType);

        if (loop)
        {
            tweenObject.loopCount = int.MaxValue;       //tweenObject.setLoopType()
        }
        if (pingpong)
        {
            tweenObject.setLoopPingPong();
        }
    }
        // Code that runs on entering the state.
        public override void OnEnter()
        {
            GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);

            Fsm.Event(onStartEvent);
            LTDescr tween = LeanTween.value(go, doOnUpdate, fromValue.Value, toValue.Value, time.Value);

            LeanTweenID.Value = tween.id;

            tween.setEase(easeType);
            tween.setDelay(delay.Value);

            if (noOfRepeat.Value > 0)
            {
                tween.setRepeat(noOfRepeat.Value);
            }

            switch (LoopType)
            {
            case LTLoop.clamp:
                tween.setLoopClamp();
                break;

            case LTLoop.once:
                tween.setLoopOnce();
                break;

            case LTLoop.pingpong:
                tween.setLoopPingPong();
                break;
            }

            tween.setOnComplete(doOnComplete);
            tween.setOnUpdate(doOnUpdate);
            tween.setUseEstimatedTime(useEstimatedTime.Value);
            tween.setUseFrames(useFrames.Value);
        }
Exemple #23
0
    private void HandleTween()
    {
        if (_objectToAnimate == null)
        {
            _objectToAnimate = gameObject;
        }
        if (_objectToDisable == null)
        {
            _objectToDisable = gameObject;
        }

        switch (_animationType)
        {
        case AnimationType.MoveX:
            MoveX();
            break;

        case AnimationType.MoveY:
            MoveY();
            break;

        case AnimationType.Move:
            Move();
            break;

        case AnimationType.MoveLocalX:
            MoveLocalX();
            break;

        case AnimationType.MoveLocalY:
            MoveLocalY();
            break;

        case AnimationType.MoveLocal:
            MoveLocal();
            break;

        case AnimationType.RotateX:
            RotateX();
            break;

        case AnimationType.RotateY:
            RotateY();
            break;

        case AnimationType.RotateZ:
            RotateZ();
            break;

        case AnimationType.Rotate:
            Rotate();
            break;

        case AnimationType.RotateLocal:
            RotateLocal();
            break;

        case AnimationType.ScaleX:
            ScaleX();
            break;

        case AnimationType.ScaleY:
            ScaleY();
            break;

        case AnimationType.ScaleZ:
            ScaleZ();
            break;

        case AnimationType.Scale:
            Scale();
            break;

        case AnimationType.Alpha:
            Fade();
            break;

        case AnimationType.Color:
            Color();
            break;
        }

        _tweenObject.setDelay(_delay);
        _tweenObject.setEase(_easeType);

        if (_loop)
        {
            _tweenObject.setLoopCount(int.MaxValue);
        }
        if (_pingPong)
        {
            _tweenObject.setLoopPingPong();
        }
    }
Exemple #24
0
        //Handles actual tween logic
        public void HandleTween(bool isDisabling, UIAnimationTypes animationType, LeanTweenType easeType, float delay, float duration, bool loop, bool pingpong, bool startPositionOffset)
        {
            //Checks whether this script should be animating this object
            if (objectToAnimate == null)
            {
                objectToAnimate = gameObject;
            }

            //Switch for different animation types
            switch (animationType)
            {
            //Fade
            case UIAnimationTypes.Fade:
                if (isDisabling)
                {
                    //Fade out
                    Fade(animationSettings.outFrom, animationSettings.outTo, startPositionOffset, duration);
                }
                else
                {
                    //Fade in
                    Fade(animationSettings.inFrom, animationSettings.inTo, startPositionOffset, duration);
                }
                break;

            //Move
            case UIAnimationTypes.Move:
                if (isDisabling)
                {
                    //Move out
                    MoveAbsolute(animationSettings.outFrom, animationSettings.outTo, duration);
                }
                else
                {
                    //Move in
                    MoveAbsolute(animationSettings.inFrom, animationSettings.inTo, duration);
                }
                break;

            //Scale
            case UIAnimationTypes.Scale:
                if (isDisabling)
                {
                    //Scale out
                    Scale(animationSettings.outFrom, animationSettings.outTo, startPositionOffset, duration);
                }
                else
                {
                    //Scale in
                    Scale(animationSettings.inFrom, animationSettings.inTo, startPositionOffset, duration);
                }
                break;
            }

            //Tween settings
            tweenObject.setDelay(delay);
            tweenObject.setEase(easeType);

            //Loop settings
            if (loop)
            {
                tweenObject.loopCount = int.MaxValue;
            }

            //Ping pong effect
            if (pingpong)
            {
                tweenObject.setLoopPingPong();
            }
        }
Exemple #25
0
    private void HandleTween()
    {
        switch (animationType)
        {
        case AnimationType.MoveX:
            MoveX();
            break;

        case AnimationType.MoveY:
            MoveY();
            break;

        case AnimationType.Move:
            Move();
            break;

        case AnimationType.MoveLocalX:
            MoveLocalX();
            break;

        case AnimationType.MoveLocalY:
            MoveLocalY();
            break;

        case AnimationType.MoveLocal:
            MoveLocal();
            break;

        case AnimationType.RotateX:
            RotateX();
            break;

        case AnimationType.RotateY:
            RotateY();
            break;

        case AnimationType.RotateZ:
            RotateZ();
            break;

        case AnimationType.Rotate:
            Rotate();
            break;

        case AnimationType.RotateLocal:
            RotateLocal();
            break;

        case AnimationType.ScaleX:
            ScaleX();
            break;

        case AnimationType.ScaleY:
            ScaleY();
            break;

        case AnimationType.ScaleZ:
            ScaleZ();
            break;

        case AnimationType.Scale:
            Scale();
            break;

        case AnimationType.Alpha:
            Fade();
            break;

        case AnimationType.Color:
            Color();
            break;
        }

        _tweenObject.setDelay(delay);
        _tweenObject.setEase(easeType);
        _tweenObject.setIgnoreTimeScale(useUnscaledTime);

        if (loop)
        {
            _tweenObject.setLoopCount(int.MaxValue);
        }
        if (pingPong)
        {
            _tweenObject.setLoopPingPong();
        }
    }
Exemple #26
0
        private void HandleTween()
        {
            _tweenObject = null;
            switch (animationType)
            {
            case UIAnimationTypes.Fade:
                Fade();
                break;

            case UIAnimationTypes.Move:
                MoveAbsolute();
                break;

            case UIAnimationTypes.Scale:
                Scale();
                break;

            case UIAnimationTypes.ScaleX:
                from = new Vector3(from.x, transform.localScale.y, transform.localScale.z);
                to   = new Vector3(to.x, transform.localScale.y, transform.localScale.z);
                Scale();
                break;

            case UIAnimationTypes.ScaleY:
                from = new Vector3(transform.localScale.x, from.y, transform.localScale.z);
                to   = new Vector3(transform.localScale.x, to.y, transform.localScale.z);
                Scale();
                break;

            case UIAnimationTypes.Rect:
                Rect();
                break;
            }

            var delayResult = delay;

            if (multiplyDelayByChildIndex)
            {
                delayResult = delay * transform.GetSiblingIndex();
            }

            _tweenObject.setDelay(delayResult);

            if ((delayResult >= 0f) && hideDuringDelay)
            {
                CanvasGroup group = objectToAnimate.GetComponent <CanvasGroup>();
                if (group == null)
                {
                    group = objectToAnimate.AddComponent <CanvasGroup>();
                }

                group.alpha = 0;
                //Show the object when it starts
                _tweenObject.setOnStart(() =>
                {
                    group.alpha = 1;
                });
            }

            _tweenObject.setEase(easeType);

            if (loop)
            {
                _tweenObject.loopCount = int.MaxValue;
            }
            if (pingpong)
            {
                _tweenObject.setLoopPingPong();
            }
            if (onComplete != null)
            {
                _tweenObject.setOnComplete(onComplete);
            }
        }
        public void HandleTween()
        {
            if (objectToAnimate == null)
            {
                objectToAnimate = gameObject;
            }

            switch (animationType)
            {
            case UIAnimationTypes.Fade:
                Fade();
                break;

            case UIAnimationTypes.Move:
                MoveAbsolute();
                break;

            case UIAnimationTypes.Scale:
                Scale();
                break;

            case UIAnimationTypes.ScaleX:
                from = new Vector3(from.x, transform.localScale.y, transform.localScale.z);
                to   = new Vector3(to.x, transform.localScale.y, transform.localScale.z);
                Scale();
                break;

            case UIAnimationTypes.ScaleY:
                from = new Vector3(transform.localScale.x, from.y, transform.localScale.z);
                to   = new Vector3(transform.localScale.x, to.y, transform.localScale.z);
                Scale();
                break;
            }

            _tweenObject.setDelay(delay);

            if ((delay >= 0f) && hideDuringDelay)
            {
                CanvasGroup group = objectToAnimate.GetComponent <CanvasGroup>();
                if (group == null)
                {
                    group = objectToAnimate.AddComponent <CanvasGroup>();
                }

                group.alpha = 0;
                //Show the object when it starts
                _tweenObject.setOnStart(() =>
                {
                    group.alpha = 1;
                });
            }

            _tweenObject.setEase(easeType);

            if (loop)
            {
                _tweenObject.loopCount = int.MaxValue;
            }
            if (pingpong)
            {
                _tweenObject.setLoopPingPong();
            }
        }
Exemple #28
0
        private void buildTween(LeanTweenItem item, float delayAdd, bool generateCode)
        {
            float delay = item.delay + delayAdd;
            bool  code  = generateCode;
            float d     = item.duration;

            // Debug.Log("item:"+item.action);
            if (item.action == TweenAction.ALPHA)
            {
                tween = code ? append("alpha", item.to.x, d) : LeanTween.alpha(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.ALPHA_VERTEX)
            {
                tween = code ? append("alphaVertex", item.to.x, d) : LeanTween.alphaVertex(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE)
            {
                tween = code ? append("move", item.to, d) : LeanTween.move(gameObject, item.to, d);
            }
            else if (item.action == TweenAction.MOVE_LOCAL)
            {
                tween = code ? append("moveLocal", item.to, d) : LeanTween.moveLocal(gameObject, item.to, d);
            }
            else if (item.action == TweenAction.MOVE_LOCAL_X)
            {
                tween = code ? append("moveLocalX", item.to.x, d) : LeanTween.moveLocalX(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE_LOCAL_Y)
            {
                tween = code ? append("moveLocalY", item.to.x, d) : LeanTween.moveLocalY(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE_LOCAL_Z)
            {
                tween = code ? append("moveLocalZ", item.to.x, d) : LeanTween.moveLocalZ(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE_X)
            {
                tween = code ? append("moveX", item.to.x, d) : LeanTween.moveX(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE_Y)
            {
                tween = code ? append("moveY", item.to.x, d) : LeanTween.moveY(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE_Z)
            {
                tween = code ? append("moveZ", item.to.x, d) : LeanTween.moveZ(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE_CURVED)
            {
                tween = code ? append("move", item.bezierPath ? item.bezierPath.vec3 : null, d) : LeanTween.move(gameObject, item.bezierPath.vec3, d);
                if (item.orientToPath)
                {
                    if (code)
                    {
                        codeBuild.Append(".setOrientToPath(" + item.orientToPath + ")");
                    }
                    else
                    {
                        tween.setOrientToPath(item.orientToPath);
                    }
                }
                if (item.isPath2d)
                {
                    if (code)
                    {
                        codeBuild.Append(".setOrientToPath2d(true)");
                    }
                    else
                    {
                        tween.setOrientToPath2d(item.isPath2d);
                    }
                }
            }
            else if (item.action == TweenAction.MOVE_CURVED_LOCAL)
            {
                tween = code ? append("moveLocal", item.bezierPath ? item.bezierPath.vec3 : null, d) : LeanTween.moveLocal(gameObject, item.bezierPath.vec3, d);
                if (item.orientToPath)
                {
                    if (code)
                    {
                        codeBuild.Append(".setOrientToPath(" + item.orientToPath + ")");
                    }
                    else
                    {
                        tween.setOrientToPath(item.orientToPath);
                    }
                }
                if (item.isPath2d)
                {
                    if (code)
                    {
                        codeBuild.Append(".setOrientToPath2d(true)");
                    }
                    else
                    {
                        tween.setOrientToPath2d(item.isPath2d);
                    }
                }
            }
            else if (item.action == TweenAction.MOVE_SPLINE)
            {
                tween = code ? append("moveSpline", item.splinePath ? item.splinePath.splineVector() : null, d) : LeanTween.moveSpline(gameObject, item.splinePath.splineVector(), d);
                if (item.orientToPath)
                {
                    if (code)
                    {
                        codeBuild.Append(".setOrientToPath(" + item.orientToPath + ")");
                    }
                    else
                    {
                        tween.setOrientToPath(item.orientToPath);
                    }
                }
                if (item.isPath2d)
                {
                    if (code)
                    {
                        codeBuild.Append(".setOrientToPath2d(true)");
                    }
                    else
                    {
                        tween.setOrientToPath2d(item.isPath2d);
                    }
                }
            }
            else if (item.action == TweenAction.ROTATE)
            {
                tween = code ? append("rotate", item.to, d) : LeanTween.rotate(gameObject, item.to, d);
            }
            else if (item.action == TweenAction.ROTATE_AROUND)
            {
                if (generateCode)
                {
                    codeBuild.Append(tabs + "LeanTween.rotateAround(gameObject, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)");
                }
                else
                {
                    tween = LeanTween.rotateAround(gameObject, item.axis, item.to.x, d);
                }
            }
            else if (item.action == TweenAction.ROTATE_AROUND_LOCAL)
            {
                if (generateCode)
                {
                    codeBuild.Append(tabs + "LeanTween.rotateAroundLocal(gameObject, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)");
                }
                else
                {
                    tween = LeanTween.rotateAroundLocal(gameObject, item.axis, item.to.x, d);
                }
            }
            else if (item.action == TweenAction.ROTATE_LOCAL)
            {
                tween = code ? append("rotateLocal", item.to, d) : LeanTween.rotateLocal(gameObject, item.to, d);
            }
            else if (item.action == TweenAction.ROTATE_X)
            {
                tween = code ? append("rotateX", item.to.x, d) : LeanTween.rotateX(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.ROTATE_Y)
            {
                tween = code ? append("rotateY", item.to.x, d) : LeanTween.rotateY(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.ROTATE_Z)
            {
                tween = code ? append("rotateZ", item.to.x, d) : LeanTween.rotateZ(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.SCALE)
            {
                tween = code ? append("scale", item.to, d) : LeanTween.scale(gameObject, item.to, d);
            }
            else if (item.action == TweenAction.SCALE_X)
            {
                tween = code ? append("scaleX", item.to.x, d) : LeanTween.scaleX(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.SCALE_Y)
            {
                tween = code ? append("scaleY", item.to.x, d) : LeanTween.scaleY(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.SCALE_Z)
            {
                tween = code ? append("scaleZ", item.to.x, d) : LeanTween.scaleZ(gameObject, item.to.x, d);
            }
                        #if !UNITY_4_3 && !UNITY_4_5
            else if (item.action == TweenAction.CANVAS_MOVE)
            {
                tween = code ? appendRect("move", item.to, d) : LeanTween.move(GetComponent <RectTransform>(), item.to, d);
            }
            else if (item.action == TweenAction.CANVAS_SCALE)
            {
                tween = code ? appendRect("scale", item.to, d) : LeanTween.scale(GetComponent <RectTransform>(), item.to, d);
            }
            else if (item.action == TweenAction.CANVAS_ROTATEAROUND)
            {
                if (generateCode)
                {
                    codeBuild.Append(tabs + "LeanTween.rotateAround(rectTransform, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)");
                }
                else
                {
                    tween = LeanTween.rotateAround(GetComponent <RectTransform>(), item.axis, item.to.x, d);
                }
            }
            else if (item.action == TweenAction.CANVAS_ROTATEAROUND_LOCAL)
            {
                if (generateCode)
                {
                    codeBuild.Append(tabs + "LeanTween.rotateAroundLocal(rectTransform, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)");
                }
                else
                {
                    tween = LeanTween.rotateAroundLocal(GetComponent <RectTransform>(), item.axis, item.to.x, d);
                }
            }
            else if (item.action == TweenAction.CANVAS_ALPHA)
            {
                tween = code ? appendRect("alpha", item.to.x, d) : LeanTween.alpha(GetComponent <RectTransform>(), item.to.x, d);
            }
            else if (item.action == TweenAction.CANVAS_COLOR)
            {
                tween = code ? appendRect("color", item.colorTo, d) : LeanTween.color(GetComponent <RectTransform>(), item.colorTo, d);
            }
            else if (item.action == TweenAction.TEXT_ALPHA)
            {
                tween = code ? appendRect("textAlpha", item.to.x, d) : LeanTween.textAlpha(GetComponent <RectTransform>(), item.to.x, d);
            }
            else if (item.action == TweenAction.TEXT_COLOR)
            {
                tween = code ? appendRect("textColor", item.colorTo, d) : LeanTween.textColor(GetComponent <RectTransform>(), item.colorTo, d);
            }
            else if (item.action == TweenAction.CANVAS_PLAYSPRITE)
            {
                if (generateCode)
                {
                    codeBuild.Append(tabs + "LeanTween.play(rectTransform, sprites).setFrameRate(" + item.frameRate + "f)");
                }
                else
                {
                    tween = LeanTween.play(GetComponent <RectTransform>(), item.sprites).setFrameRate(item.frameRate);
                }
            }
                        #endif
            else if (item.action == TweenAction.COLOR)
            {
                tween = code ? append("color", item.colorTo, d) : LeanTween.color(gameObject, item.colorTo, d);
            }
            else if (item.action == TweenAction.DELAYED_SOUND)
            {
                if (generateCode)
                {
                    codeBuild.Append(tabs + "LeanTween.delayedSound(gameObject, passAudioClipHere, " + vecToStr(item.from) + ", " + d + "f)");
                }
                else
                {
                    tween = LeanTween.delayedSound(gameObject, item.audioClip, item.from, item.duration);
                }
            }
            else
            {
                tween = null;
                Debug.Log("The tween '" + item.action.ToString() + "' has not been implemented. info item:" + item);
                return;
            }


            // Append Extras
            if (generateCode)
            {
                if (delay > 0f)
                {
                    codeBuild.Append(".setDelay(" + delay + "f)");
                }
            }
            else
            {
                tween = tween.setDelay(delay);
            }
            if (item.ease == LeanTweenType.animationCurve)
            {
                if (generateCode)
                {
                    codeBuild.Append(".setEase(");
                    append(item.animationCurve);
                    codeBuild.Append(")");
                }
                else
                {
                    tween.setEase(item.animationCurve);
                }
            }
            else
            {
                if (generateCode)
                {
                    if (item.ease != LeanTweenType.linear)
                    {
                        codeBuild.Append(".setEase(LeanTweenType." + item.ease + ")");
                    }
                }
                else
                {
                    tween.setEase(item.ease);
                }
            }
            // Debug.Log("curve:"+item.animationCurve+" item.ease:"+item.ease);
            if (item.between == LeanTweenBetween.FromTo)
            {
                if (generateCode)
                {
                    codeBuild.Append(".setFrom(" + item.from + ")");
                }
                else
                {
                    tween.setFrom(item.from);
                }
            }
            if (item.doesLoop)
            {
                if (generateCode)
                {
                    codeBuild.Append(".setRepeat(" + item.loopCount + ")");
                }
                else
                {
                    tween.setRepeat(item.loopCount);
                }

                if (item.loopType == LeanTweenType.pingPong)
                {
                    if (generateCode)
                    {
                        codeBuild.Append(".setLoopPingPong()");
                    }
                    else
                    {
                        tween.setLoopPingPong();
                    }
                }
            }
            if (generateCode)
            {
                codeBuild.Append(";\n");
            }
        }
 private void Start()
 {
     tweenObject = LeanTween.move(gameObject, transform.position + (Vector3.up * distance), duration);
     tweenObject.setLoopPingPong();
     tweenObject.setEase(easeType);
 }
    // -------------------------------------------------------------------------------

    private void SetTweenType()
    {
        switch (TweenType)
        {
        case LeanTweenType.linear:              mTweenDescriptor.setEaseLinear(); break;

        case LeanTweenType.easeOutQuad:         mTweenDescriptor.setEaseOutQuad(); break;

        case LeanTweenType.easeInQuad:          mTweenDescriptor.setEaseInQuad(); break;

        case LeanTweenType.easeInOutQuad:       mTweenDescriptor.setEaseInOutQuad(); break;

        case LeanTweenType.easeInCubic:         mTweenDescriptor.setEaseInCubic(); break;

        case LeanTweenType.easeOutCubic:        mTweenDescriptor.setEaseOutCubic(); break;

        case LeanTweenType.easeInOutCubic:      mTweenDescriptor.setEaseInOutCubic(); break;

        case LeanTweenType.easeInQuart:         mTweenDescriptor.setEaseInQuart(); break;

        case LeanTweenType.easeOutQuart:        mTweenDescriptor.setEaseOutQuart(); break;

        case LeanTweenType.easeInOutQuart:      mTweenDescriptor.setEaseInOutQuart(); break;

        case LeanTweenType.easeInQuint:         mTweenDescriptor.setEaseInQuint(); break;

        case LeanTweenType.easeOutQuint:        mTweenDescriptor.setEaseOutQuint(); break;

        case LeanTweenType.easeInOutQuint:      mTweenDescriptor.setEaseInOutQuint(); break;

        case LeanTweenType.easeInSine:          mTweenDescriptor.setEaseInSine(); break;

        case LeanTweenType.easeOutSine:         mTweenDescriptor.setEaseOutSine(); break;

        case LeanTweenType.easeInOutSine:       mTweenDescriptor.setEaseInOutSine(); break;

        case LeanTweenType.easeInExpo:          mTweenDescriptor.setEaseInExpo(); break;

        case LeanTweenType.easeOutExpo:         mTweenDescriptor.setEaseOutExpo(); break;

        case LeanTweenType.easeInOutExpo:       mTweenDescriptor.setEaseInOutExpo(); break;

        case LeanTweenType.easeInCirc:          mTweenDescriptor.setEaseInCirc(); break;

        case LeanTweenType.easeOutCirc:         mTweenDescriptor.setEaseOutCirc(); break;

        case LeanTweenType.easeInOutCirc:       mTweenDescriptor.setEaseInOutCirc(); break;

        case LeanTweenType.easeInBounce:        mTweenDescriptor.setEaseInBounce(); break;

        case LeanTweenType.easeOutBounce:       mTweenDescriptor.setEaseOutBounce(); break;

        case LeanTweenType.easeInOutBounce:     mTweenDescriptor.setEaseInOutBounce(); break;

        case LeanTweenType.easeInBack:          mTweenDescriptor.setEaseInBack(); break;

        case LeanTweenType.easeOutBack:         mTweenDescriptor.setEaseOutBack(); break;

        case LeanTweenType.easeInOutBack:       mTweenDescriptor.setEaseInOutBack(); break;

        case LeanTweenType.easeInElastic:       mTweenDescriptor.setEaseInElastic(); break;

        case LeanTweenType.easeOutElastic:      mTweenDescriptor.setEaseOutElastic(); break;

        case LeanTweenType.easeInOutElastic:    mTweenDescriptor.setEaseInOutElastic(); break;

        case LeanTweenType.easeSpring:          mTweenDescriptor.setEaseSpring(); break;

        case LeanTweenType.easeShake:           mTweenDescriptor.setEaseShake(); break;

        case LeanTweenType.punch:               mTweenDescriptor.setEasePunch(); break;

        case LeanTweenType.once:                mTweenDescriptor.setLoopOnce(); break;

        case LeanTweenType.clamp:               mTweenDescriptor.setLoopClamp(); break;

        case LeanTweenType.pingPong:            mTweenDescriptor.setLoopPingPong(); break;

        case LeanTweenType.animationCurve:      Debug.LogError("Can't set AnimationCurve Tween this way..."); break;

        default:                                Debug.LogError("Invalid TweenType specified. Falling back to Linear"); break;
        }
    }