Esempio n. 1
0
 /// <summary>Tweens a Rigidbody2D's position to the given value.
 /// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 public static TweenerCore<Vector2, Vector2, VectorOptions> DOMove(this Rigidbody2D target, Vector2 endValue, float duration, bool snapping = false)
 {
     TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.position, target.MovePosition, endValue, duration);
     t.SetOptions(snapping).SetTarget(target);
     return t;
 }
 /// <summary>Tweens an Image's color to the given value.
 /// Also stores the image as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 public static Tweener DOColor(this Image target, Color endValue, float duration)
 {
     return(DOTween.To(() => target.color, x => target.color = x, endValue, duration).SetTarget(target));
 }
Esempio n. 3
0
 /// <summary>Tweens a Rigidbody2D's Y position to the given value.
 /// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
 /// <par name="endValue">The end value to reach</par><par name="duration">The duration of the tween</par>
 /// <par name="snapping">If TRUE the tween will smoothly snap all values to integers</par>
 public static Tweener DOMoveY(this Rigidbody2D target, float endValue, float duration, bool snapping = false)
 {
     return(DOTween.To(() => target.position, target.MovePosition, new Vector2(0, endValue), duration)
            .SetOptions(AxisConstraint.Y, snapping).SetTarget(target));
 }
 /// <summary>Tweens a RectTransform's sizeDelta to the given value.
 /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 public static Tweener DOSizeDelta(this RectTransform target, Vector2 endValue, float duration, bool snapping = false)
 {
     return(DOTween.To(() => target.sizeDelta, x => target.sizeDelta = x, endValue, duration)
            .SetOptions(snapping).SetTarget(target));
 }
 /// <summary>Tweens a Slider's value to the given value.
 /// Also stores the Slider as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 public static Tweener DOValue(this Slider target, float endValue, float duration, bool snapping = false)
 {
     return(DOTween.To(() => target.value, x => target.value = x, endValue, duration)
            .SetOptions(snapping).SetTarget(target));
 }
 /// <summary>Tweens a RectTransform's anchoredPosition3D to the given value.
 /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 public static Tweener DOAnchorPos3D(this RectTransform target, Vector3 endValue, float duration, bool snapping = false)
 {
     return(DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, endValue, duration)
            .SetOptions(snapping).SetTarget(target));
 }
 /// <summary>Tweens a RectTransform's pivot to the given value.
 /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 public static Tweener DOPivot(this RectTransform target, Vector2 endValue, float duration)
 {
     return(DOTween.To(() => target.pivot, x => target.pivot = x, endValue, duration)
            .SetTarget(target));
 }
Esempio n. 8
0
 /// <summary>Tweens a LineRenderer's color to the given value.
 /// Also stores the LineRenderer as the tween's target so it can be used for filtered operations.
 /// <para>Note that this method requires to also insert the start colors for the tween,
 /// since LineRenderers have no way to get them.</para></summary>
 /// <param name="startValue">The start value to tween from</param>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 public static Tweener DOColor(this LineRenderer target, Color2 startValue, Color2 endValue, float duration)
 {
     return(DOTween.To(() => startValue, x => target.SetColors(x.ca, x.cb), endValue, duration).SetTarget(target));
 }
Esempio n. 9
0
 /// <summary>Tweens a Material's named Vector property to the given value.
 /// Also stores the material as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param>
 /// <param name="property">The name of the material property to tween</param>
 /// <param name="duration">The duration of the tween</param>
 public static Tweener DOVector(this Material target, Vector4 endValue, string property, float duration)
 {
     return(DOTween.To(() => target.GetVector(property), x => target.SetVector(property, x), endValue, duration).SetTarget(target));
 }
Esempio n. 10
0
 /// <summary>Tweens a Light's intensity to the given value.
 /// Also stores the light as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 public static Tweener DOIntensity(this Light target, float endValue, float duration)
 {
     return(DOTween.To(() => target.intensity, x => target.intensity = x, endValue, duration).SetTarget(target));
 }
Esempio n. 11
0
 /// <summary>Tweens a Light's shadowStrength to the given value.
 /// Also stores the light as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 public static Tweener DOShadowStrength(this Light target, float endValue, float duration)
 {
     return(DOTween.To(() => target.shadowStrength, x => target.shadowStrength = x, endValue, duration).SetTarget(target));
 }
Esempio n. 12
0
 /// <summary>Tweens a Camera's backgroundColor to the given value.
 /// Also stores the camera as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 public static Tweener DOColor(this Camera target, Color endValue, float duration)
 {
     return(DOTween.To(() => target.backgroundColor, x => target.backgroundColor = x, endValue, duration).SetTarget(target));
 }
Esempio n. 13
0
 /// <summary>Tweens a Rigidbody2D's rotation to the given value.
 /// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 public static TweenerCore<float, float, FloatOptions> DORotate(this Rigidbody2D target, float endValue, float duration)
 {
     TweenerCore<float, float, FloatOptions> t = DOTween.To(() => target.rotation, target.MoveRotation, endValue, duration);
     t.SetTarget(target);
     return t;
 }
Esempio n. 14
0
 /// <summary>Tweens a Rigidbody2D's X position to the given value.
 /// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 public static TweenerCore<Vector2, Vector2, VectorOptions> DOMoveX(this Rigidbody2D target, float endValue, float duration, bool snapping = false)
 {
     TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.position, target.MovePosition, new Vector2(endValue, 0), duration);
     t.SetOptions(AxisConstraint.X, snapping).SetTarget(target);
     return t;
 }
Esempio n. 15
0
 /// <summary>Tweens a Outline's effectDistance to the given value.
 /// Also stores the Outline as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 public static Tweener DOScale(this Outline target, Vector2 endValue, float duration)
 {
     return(DOTween.To(() => target.effectDistance, x => target.effectDistance = x, endValue, duration)
            .SetTarget(target));
 }
Esempio n. 16
0
 /// <summary>Tweens a TrailRenderer's time to the given value.
 /// Also stores the TrailRenderer as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 public static Tweener DOTime(this TrailRenderer target, float endValue, float duration)
 {
     return(DOTween.To(() => target.time, x => target.time = x, endValue, duration)
            .SetTarget(target));
 }
Esempio n. 17
0
 /// <summary>Tweens a CanvasGroup's alpha color to the given value.
 /// Also stores the canvasGroup as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 public static Tweener DOFade(this CanvasGroup target, float endValue, float duration)
 {
     return(DOTween.To(() => target.alpha, x => target.alpha = x, endValue, duration)
            .SetTarget(target));
 }
Esempio n. 18
0
 /// <summary>Tweens a Transform's localPosition to the given value.
 /// Also stores the transform as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 public static Tweener DOLocalMove(this Transform target, Vector3 endValue, float duration, bool snapping = false)
 {
     return(DOTween.To(() => target.localPosition, x => target.localPosition = x, endValue, duration)
            .SetOptions(snapping).SetTarget(target));
 }
Esempio n. 19
0
 /// <summary>Tweens a RectTransform's anchoredPosition3D Z to the given value.
 /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 public static Tweener DOAnchorPos3DZ(this RectTransform target, float endValue, float duration, bool snapping = false)
 {
     return(DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, new Vector3(0, 0, endValue), duration)
            .SetOptions(AxisConstraint.Z, snapping).SetTarget(target));
 }
Esempio n. 20
0
 /// <summary>Tweens a Transform's Z localPosition to the given value.
 /// Also stores the transform as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 public static Tweener DOLocalMoveZ(this Transform target, float endValue, float duration, bool snapping = false)
 {
     return(DOTween.To(() => target.localPosition, x => target.localPosition = x, new Vector3(0, 0, endValue), duration)
            .SetOptions(AxisConstraint.Z, snapping).SetTarget(target));
 }
Esempio n. 21
0
 /// <summary>Tweens a RectTransform's pivot Y to the given value.
 /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 public static Tweener DOPivotY(this RectTransform target, float endValue, float duration)
 {
     return(DOTween.To(() => target.pivot, x => target.pivot = x, new Vector2(0, endValue), duration)
            .SetOptions(AxisConstraint.Y).SetTarget(target));
 }
Esempio n. 22
0
 /// <summary>Tweens a Transform's localScale to the given value.
 /// Also stores the transform as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 public static Tweener DOScale(this Transform target, Vector3 endValue, float duration)
 {
     return(DOTween.To(() => target.localScale, x => target.localScale = x, endValue, duration).SetTarget(target));
 }
Esempio n. 23
0
 /// <summary>Tweens a ScrollRect's verticalNormalizedPosition to the given value.
 /// Also stores the ScrollRect as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 public static Tweener DOVerticalNormalizedPos(this ScrollRect target, float endValue, float duration, bool snapping = false)
 {
     return(DOTween.To(() => target.verticalNormalizedPosition, x => target.verticalNormalizedPosition = x, endValue, duration)
            .SetOptions(snapping).SetTarget(target));
 }
Esempio n. 24
0
 /// <summary>Tweens a Transform's Z localScale to the given value.
 /// Also stores the transform as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 public static Tweener DOScaleZ(this Transform target, float endValue, float duration)
 {
     return(DOTween.To(() => target.localScale, x => target.localScale = x, new Vector3(0, 0, endValue), duration)
            .SetOptions(AxisConstraint.Z)
            .SetTarget(target));
 }
Esempio n. 25
0
 /// <summary>Tweens a Text's text to the given value.
 /// Also stores the Text as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end string to tween to</param><param name="duration">The duration of the tween</param>
 /// <param name="richTextEnabled">If TRUE (default), rich text will be interpreted correctly while animated,
 /// otherwise all tags will be considered as normal text</param>
 /// <param name="scrambleMode">The type of scramble mode to use, if any</param>
 /// <param name="scrambleChars">A string containing the characters to use for scrambling.
 /// Use as many characters as possible (minimum 10) because DOTween uses a fast scramble mode which gives better results with more characters.
 /// Leave it to NULL (default) to use default ones</param>
 public static Tweener DOText(this Text target, string endValue, float duration, bool richTextEnabled = true, ScrambleMode scrambleMode = ScrambleMode.None, string scrambleChars = null)
 {
     return(DOTween.To(() => target.text, x => target.text = x, endValue, duration)
            .SetOptions(richTextEnabled, scrambleMode, scrambleChars)
            .SetTarget(target));
 }
Esempio n. 26
0
        public static Sequence DOLocalJump(this Transform target, Vector3 endValue, float jumpPower, int numJumps, float duration, bool snapping = false)
        {
            if (numJumps < 1)
            {
                numJumps = 1;
            }
            float    startPosY  = target.localPosition.y;
            float    offsetY    = -1f;
            bool     offsetYSet = false;
            Sequence s          = DOTween.Sequence();

            s.Append(DOTween.To(() => target.localPosition, delegate(Vector3 x)
            {
                target.localPosition = x;
            }, new Vector3(endValue.x, 0f, 0f), duration).SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear)
                     .OnUpdate(delegate
            {
                if (!offsetYSet)
                {
                    offsetYSet = false;
                    offsetY    = (s.isRelative ? endValue.y : (endValue.y - startPosY));
                }
                Vector3 localPosition = target.localPosition;
                localPosition.y      += DOVirtual.EasedValue(0f, offsetY, s.ElapsedDirectionalPercentage(), Ease.OutQuad);
                target.localPosition  = localPosition;
            })).Join(DOTween.To(() => target.localPosition, delegate(Vector3 x)
            {
                target.localPosition = x;
            }, new Vector3(0f, 0f, endValue.z), duration).SetOptions(AxisConstraint.Z, snapping).SetEase(Ease.Linear)).Join(DOTween.To(() => target.localPosition, delegate(Vector3 x)
            {
                target.localPosition = x;
            }, new Vector3(0f, jumpPower, 0f), duration / (float)(numJumps * 2)).SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad)
                                                                                                                            .SetRelative()
                                                                                                                            .SetLoops(numJumps * 2, LoopType.Yoyo))
            .SetTarget(target)
            .SetEase(DOTween.defaultEaseType);
            return(s);
        }
Esempio n. 27
0
 /// <summary>Tweens a Rigidbody2D's position to the given value.
 /// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
 /// <par name="endValue">The end value to reach</par><par name="duration">The duration of the tween</par>
 /// <par name="snapping">If TRUE the tween will smoothly snap all values to integers</par>
 public static Tweener DOMove(this Rigidbody2D target, Vector2 endValue, float duration, bool snapping = false)
 {
     return(DOTween.To(() => target.position, target.MovePosition, endValue, duration)
            .SetOptions(snapping).SetTarget(target));
 }
 /// <summary>Tweens an AudioSource's pitch to the given value.
 /// Also stores the AudioSource as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 public static Tweener DOPitch(this AudioSource target, float endValue, float duration)
 {
     return(DOTween.To(() => target.pitch, x => target.pitch = x, endValue, duration).SetTarget(target));
 }
Esempio n. 29
0
 /// <summary>Tweens a Rigidbody2D's rotation to the given value.
 /// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
 /// <par name="endValue">The end value to reach</par><par name="duration">The duration of the tween</par>
 public static Tweener DORotate(this Rigidbody2D target, float endValue, float duration)
 {
     return(DOTween.To(() => target.rotation, target.MoveRotation, endValue, duration)
            .SetTarget(target));
 }
Esempio n. 30
0
 /// <summary>Tweens a SlicedSprite's dimensions to the given value.
 /// Also stores the SlicedSprite as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 public static Tweener DOScaleX(this tk2dSlicedSprite target, float endValue, float duration)
 {
     return(DOTween.To(() => target.dimensions, x => target.dimensions = x, new Vector2(endValue, 0), duration)
            .SetOptions(AxisConstraint.X)
            .SetTarget(target));
 }