Example #1
0
        /// <summary>
        /// Tweens a value from "From" to "To".
        /// </summary>
        /// <param name="data">The tween data.</param>
        /// <returns>The started tween reference.</returns>
        public Tween StartValueTo(ValueToAnimation data)
        {
            string id = tweenIdentifier.ToString();

            iTween.EaseType easeType = tweenTypeDictionary[data.EaseType];

            Hashtable args = new Hashtable();

            args["name"]             = id;
            args["onupdatetarget"]   = data.GameObject;
            args["onupdate"]         = data.OnUpdate;
            args["from"]             = 0f;
            args["to"]               = 1f;
            args["time"]             = data.Duration;
            args["delay"]            = data.Delay;
            args["easetype"]         = easeType;
            args["oncompletetarget"] = data.GameObject;
            args["oncomplete"]       = data.OnComplete;

            if (data.PingPongLoop)
            {
                args["looptype"] = iTween.LoopType.pingPong;
            }

            iTween.ValueTo(data.GameObject, args);

            tweenIdentifier++;
            return(new Tween(id));
        }
Example #2
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));
        }
Example #3
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)
        {
            Ease easeType = tweenTypeDictionary[data.EaseType];

            float   value = 0;
            Tweener t     = DOTween.To(
                getter: () => value,
                setter: x => value = x,
                endValue: 1f,
                duration: data.Duration
                )
                            .SetDelay(data.Delay)
                            .SetEase(easeType)
                            .SetLoops(data.PingPongLoop ? -1 : 0, LoopType.Yoyo)
                            .OnUpdate(() => data.OnUpdate(value))
                            .OnComplete(() => data.OnComplete());

            return(new Tween(t));
        }