< Summary

Class:DG.Tweening.DOTweenModuleUI
Assembly:DOTween.Modules
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Plugins/DOTween/Modules/DOTweenModuleUI.cs
Covered lines:6
Uncovered lines:172
Coverable lines:178
Total lines:660
Line coverage:3.3% (6 of 178)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
DOFade(...)0%110100%
DOColor(...)0%2100%
DOFade(...)0%2100%
DOColor(...)0%2100%
DOFade(...)0%2100%
DOFillAmount(...)0%12300%
DOGradientColor(...)0%42600%
DOFlexibleSize(...)0%2100%
DOMinSize(...)0%2100%
DOPreferredSize(...)0%2100%
DOColor(...)0%2100%
DOFade(...)0%2100%
DOScale(...)0%2100%
DOAnchorPos(...)0%2100%
DOAnchorPosX(...)0%2100%
DOAnchorPosY(...)0%110100%
DOAnchorPos3D(...)0%2100%
DOAnchorPos3DX(...)0%2100%
DOAnchorPos3DY(...)0%2100%
DOAnchorPos3DZ(...)0%2100%
DOAnchorMax(...)0%2100%
DOAnchorMin(...)0%2100%
DOPivot(...)0%2100%
DOPivotX(...)0%2100%
DOPivotY(...)0%2100%
DOSizeDelta(...)0%2100%
DOPunchAnchorPos(...)0%2100%
DOShakeAnchorPos(...)0%2100%
DOShakeAnchorPos(...)0%2100%
DOJumpAnchorPos(...)0%6200%
DONormalizedPos(...)0%2100%
DOHorizontalNormalizedPos(...)0%2100%
DOVerticalNormalizedPos(...)0%2100%
DOValue(...)0%2100%
DOColor(...)0%2100%
DOCounter(...)0%12300%
DOFade(...)0%2100%
DOText(...)0%12300%
DOBlendableColor(...)0%2100%
DOBlendableColor(...)0%2100%
DOBlendableColor(...)0%2100%
DOShapeCircle(...)0%2100%
SwitchToRectTransform(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Plugins/DOTween/Modules/DOTweenModuleUI.cs

#LineLine coverage
 1// Author: Daniele Giardini - http://www.demigiant.com
 2// Created: 2018/07/13
 3
 4#if true && (UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER) // MODULE_MARKER
 5
 6using System;
 7using System.Globalization;
 8using UnityEngine;
 9using UnityEngine.UI;
 10using DG.Tweening.Core;
 11using DG.Tweening.Core.Enums;
 12using DG.Tweening.Plugins;
 13using DG.Tweening.Plugins.Options;
 14using Outline = UnityEngine.UI.Outline;
 15using Text = UnityEngine.UI.Text;
 16
 17#pragma warning disable 1591
 18namespace DG.Tweening
 19{
 20  public static class DOTweenModuleUI
 21    {
 22        #region Shortcuts
 23
 24        #region CanvasGroup
 25
 26        /// <summary>Tweens a CanvasGroup's alpha color to the given value.
 27        /// Also stores the canvasGroup as the tween's target so it can be used for filtered operations</summary>
 28        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 29        public static TweenerCore<float, float, FloatOptions> DOFade(this CanvasGroup target, float endValue, float dura
 30        {
 935531            TweenerCore<float, float, FloatOptions> t = DOTween.To(() => target.alpha, x => target.alpha = x, endValue, 
 262832            t.SetTarget(target);
 262833            return t;
 34        }
 35
 36        #endregion
 37
 38        #region Graphic
 39
 40        /// <summary>Tweens an Graphic's color to the given value.
 41        /// Also stores the image as the tween's target so it can be used for filtered operations</summary>
 42        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 43        public static TweenerCore<Color, Color, ColorOptions> DOColor(this Graphic target, Color endValue, float duratio
 44        {
 045            TweenerCore<Color, Color, ColorOptions> t = DOTween.To(() => target.color, x => target.color = x, endValue, 
 046            t.SetTarget(target);
 047            return t;
 48        }
 49
 50        /// <summary>Tweens an Graphic's alpha color to the given value.
 51        /// Also stores the image as the tween's target so it can be used for filtered operations</summary>
 52        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 53        public static TweenerCore<Color, Color, ColorOptions> DOFade(this Graphic target, float endValue, float duration
 54        {
 055            TweenerCore<Color, Color, ColorOptions> t = DOTween.ToAlpha(() => target.color, x => target.color = x, endVa
 056            t.SetTarget(target);
 057            return t;
 58        }
 59
 60        #endregion
 61
 62        #region Image
 63
 64        /// <summary>Tweens an Image's color to the given value.
 65        /// Also stores the image as the tween's target so it can be used for filtered operations</summary>
 66        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 67        public static TweenerCore<Color, Color, ColorOptions> DOColor(this Image target, Color endValue, float duration)
 68        {
 069            TweenerCore<Color, Color, ColorOptions> t = DOTween.To(() => target.color, x => target.color = x, endValue, 
 070            t.SetTarget(target);
 071            return t;
 72        }
 73
 74        /// <summary>Tweens an Image's alpha color to the given value.
 75        /// Also stores the image as the tween's target so it can be used for filtered operations</summary>
 76        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 77        public static TweenerCore<Color, Color, ColorOptions> DOFade(this Image target, float endValue, float duration)
 78        {
 079            TweenerCore<Color, Color, ColorOptions> t = DOTween.ToAlpha(() => target.color, x => target.color = x, endVa
 080            t.SetTarget(target);
 081            return t;
 82        }
 83
 84        /// <summary>Tweens an Image's fillAmount to the given value.
 85        /// Also stores the image as the tween's target so it can be used for filtered operations</summary>
 86        /// <param name="endValue">The end value to reach (0 to 1)</param><param name="duration">The duration of the twe
 87        public static TweenerCore<float, float, FloatOptions> DOFillAmount(this Image target, float endValue, float dura
 88        {
 089            if (endValue > 1) endValue = 1;
 090            else if (endValue < 0) endValue = 0;
 091            TweenerCore<float, float, FloatOptions> t = DOTween.To(() => target.fillAmount, x => target.fillAmount = x, 
 092            t.SetTarget(target);
 093            return t;
 94        }
 95
 96        /// <summary>Tweens an Image's colors using the given gradient
 97        /// (NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
 98        /// Also stores the image as the tween's target so it can be used for filtered operations</summary>
 99        /// <param name="gradient">The gradient to use</param><param name="duration">The duration of the tween</param>
 100        public static Sequence DOGradientColor(this Image target, Gradient gradient, float duration)
 101        {
 0102            Sequence s = DOTween.Sequence();
 0103            GradientColorKey[] colors = gradient.colorKeys;
 0104            int len = colors.Length;
 0105            for (int i = 0; i < len; ++i) {
 0106                GradientColorKey c = colors[i];
 0107                if (i == 0 && c.time <= 0) {
 0108                    target.color = c.color;
 0109                    continue;
 110                }
 0111                float colorDuration = i == len - 1
 112                    ? duration - s.Duration(false) // Verifies that total duration is correct
 113                    : duration * (i == 0 ? c.time : c.time - colors[i - 1].time);
 0114                s.Append(target.DOColor(c.color, colorDuration).SetEase(Ease.Linear));
 115            }
 0116            s.SetTarget(target);
 0117            return s;
 118        }
 119
 120        #endregion
 121
 122        #region LayoutElement
 123
 124        /// <summary>Tweens an LayoutElement's flexibleWidth/Height to the given value.
 125        /// Also stores the LayoutElement as the tween's target so it can be used for filtered operations</summary>
 126        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 127        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 128        public static TweenerCore<Vector2, Vector2, VectorOptions> DOFlexibleSize(this LayoutElement target, Vector2 end
 129        {
 0130            TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => new Vector2(target.flexibleWidth, target.f
 0131                    target.flexibleWidth = x.x;
 0132                    target.flexibleHeight = x.y;
 0133                }, endValue, duration);
 0134            t.SetOptions(snapping).SetTarget(target);
 0135            return t;
 136        }
 137
 138        /// <summary>Tweens an LayoutElement's minWidth/Height to the given value.
 139        /// Also stores the LayoutElement as the tween's target so it can be used for filtered operations</summary>
 140        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 141        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 142        public static TweenerCore<Vector2, Vector2, VectorOptions> DOMinSize(this LayoutElement target, Vector2 endValue
 143        {
 0144            TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => new Vector2(target.minWidth, target.minHei
 0145                target.minWidth = x.x;
 0146                target.minHeight = x.y;
 0147            }, endValue, duration);
 0148            t.SetOptions(snapping).SetTarget(target);
 0149            return t;
 150        }
 151
 152        /// <summary>Tweens an LayoutElement's preferredWidth/Height to the given value.
 153        /// Also stores the LayoutElement as the tween's target so it can be used for filtered operations</summary>
 154        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 155        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 156        public static TweenerCore<Vector2, Vector2, VectorOptions> DOPreferredSize(this LayoutElement target, Vector2 en
 157        {
 0158            TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => new Vector2(target.preferredWidth, target.
 0159                target.preferredWidth = x.x;
 0160                target.preferredHeight = x.y;
 0161            }, endValue, duration);
 0162            t.SetOptions(snapping).SetTarget(target);
 0163            return t;
 164        }
 165
 166        #endregion
 167
 168        #region Outline
 169
 170        /// <summary>Tweens a Outline's effectColor to the given value.
 171        /// Also stores the Outline as the tween's target so it can be used for filtered operations</summary>
 172        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 173        public static TweenerCore<Color, Color, ColorOptions> DOColor(this Outline target, Color endValue, float duratio
 174        {
 0175            TweenerCore<Color, Color, ColorOptions> t = DOTween.To(() => target.effectColor, x => target.effectColor = x
 0176            t.SetTarget(target);
 0177            return t;
 178        }
 179
 180        /// <summary>Tweens a Outline's effectColor alpha to the given value.
 181        /// Also stores the Outline as the tween's target so it can be used for filtered operations</summary>
 182        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 183        public static TweenerCore<Color, Color, ColorOptions> DOFade(this Outline target, float endValue, float duration
 184        {
 0185            TweenerCore<Color, Color, ColorOptions> t = DOTween.ToAlpha(() => target.effectColor, x => target.effectColo
 0186            t.SetTarget(target);
 0187            return t;
 188        }
 189
 190        /// <summary>Tweens a Outline's effectDistance to the given value.
 191        /// Also stores the Outline as the tween's target so it can be used for filtered operations</summary>
 192        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 193        public static TweenerCore<Vector2, Vector2, VectorOptions> DOScale(this Outline target, Vector2 endValue, float 
 194        {
 0195            TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.effectDistance, x => target.effectD
 0196            t.SetTarget(target);
 0197            return t;
 198        }
 199
 200        #endregion
 201
 202        #region RectTransform
 203
 204        /// <summary>Tweens a RectTransform's anchoredPosition to the given value.
 205        /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 206        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 207        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 208        public static TweenerCore<Vector2, Vector2, VectorOptions> DOAnchorPos(this RectTransform target, Vector2 endVal
 209        {
 0210            TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.anchoredPosition, x => target.ancho
 0211            t.SetOptions(snapping).SetTarget(target);
 0212            return t;
 213        }
 214        /// <summary>Tweens a RectTransform's anchoredPosition X to the given value.
 215        /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 216        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 217        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 218        public static TweenerCore<Vector2, Vector2, VectorOptions> DOAnchorPosX(this RectTransform target, float endValu
 219        {
 0220            TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.anchoredPosition, x => target.ancho
 0221            t.SetOptions(AxisConstraint.X, snapping).SetTarget(target);
 0222            return t;
 223        }
 224        /// <summary>Tweens a RectTransform's anchoredPosition Y to the given value.
 225        /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 226        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 227        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 228        public static TweenerCore<Vector2, Vector2, VectorOptions> DOAnchorPosY(this RectTransform target, float endValu
 229        {
 2716230            TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.anchoredPosition, x => target.ancho
 593231            t.SetOptions(AxisConstraint.Y, snapping).SetTarget(target);
 593232            return t;
 233        }
 234
 235        /// <summary>Tweens a RectTransform's anchoredPosition3D to the given value.
 236        /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 237        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 238        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 239        public static TweenerCore<Vector3, Vector3, VectorOptions> DOAnchorPos3D(this RectTransform target, Vector3 endV
 240        {
 0241            TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.anchoredPosition3D, x => target.anc
 0242            t.SetOptions(snapping).SetTarget(target);
 0243            return t;
 244        }
 245        /// <summary>Tweens a RectTransform's anchoredPosition3D X to the given value.
 246        /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 247        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 248        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 249        public static TweenerCore<Vector3, Vector3, VectorOptions> DOAnchorPos3DX(this RectTransform target, float endVa
 250        {
 0251            TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.anchoredPosition3D, x => target.anc
 0252            t.SetOptions(AxisConstraint.X, snapping).SetTarget(target);
 0253            return t;
 254        }
 255        /// <summary>Tweens a RectTransform's anchoredPosition3D Y to the given value.
 256        /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 257        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 258        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 259        public static TweenerCore<Vector3, Vector3, VectorOptions> DOAnchorPos3DY(this RectTransform target, float endVa
 260        {
 0261            TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.anchoredPosition3D, x => target.anc
 0262            t.SetOptions(AxisConstraint.Y, snapping).SetTarget(target);
 0263            return t;
 264        }
 265        /// <summary>Tweens a RectTransform's anchoredPosition3D Z to the given value.
 266        /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 267        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 268        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 269        public static TweenerCore<Vector3, Vector3, VectorOptions> DOAnchorPos3DZ(this RectTransform target, float endVa
 270        {
 0271            TweenerCore<Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.anchoredPosition3D, x => target.anc
 0272            t.SetOptions(AxisConstraint.Z, snapping).SetTarget(target);
 0273            return t;
 274        }
 275
 276        /// <summary>Tweens a RectTransform's anchorMax to the given value.
 277        /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 278        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 279        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 280        public static TweenerCore<Vector2, Vector2, VectorOptions> DOAnchorMax(this RectTransform target, Vector2 endVal
 281        {
 0282            TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.anchorMax, x => target.anchorMax = 
 0283            t.SetOptions(snapping).SetTarget(target);
 0284            return t;
 285        }
 286
 287        /// <summary>Tweens a RectTransform's anchorMin to the given value.
 288        /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 289        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 290        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 291        public static TweenerCore<Vector2, Vector2, VectorOptions> DOAnchorMin(this RectTransform target, Vector2 endVal
 292        {
 0293            TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.anchorMin, x => target.anchorMin = 
 0294            t.SetOptions(snapping).SetTarget(target);
 0295            return t;
 296        }
 297
 298        /// <summary>Tweens a RectTransform's pivot to the given value.
 299        /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 300        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 301        public static TweenerCore<Vector2, Vector2, VectorOptions> DOPivot(this RectTransform target, Vector2 endValue, 
 302        {
 0303            TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.pivot, x => target.pivot = x, endVa
 0304            t.SetTarget(target);
 0305            return t;
 306        }
 307        /// <summary>Tweens a RectTransform's pivot X to the given value.
 308        /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 309        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 310        public static TweenerCore<Vector2, Vector2, VectorOptions> DOPivotX(this RectTransform target, float endValue, f
 311        {
 0312            TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.pivot, x => target.pivot = x, new V
 0313            t.SetOptions(AxisConstraint.X).SetTarget(target);
 0314            return t;
 315        }
 316        /// <summary>Tweens a RectTransform's pivot Y to the given value.
 317        /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 318        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 319        public static TweenerCore<Vector2, Vector2, VectorOptions> DOPivotY(this RectTransform target, float endValue, f
 320        {
 0321            TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.pivot, x => target.pivot = x, new V
 0322            t.SetOptions(AxisConstraint.Y).SetTarget(target);
 0323            return t;
 324        }
 325
 326        /// <summary>Tweens a RectTransform's sizeDelta to the given value.
 327        /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 328        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 329        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 330        public static TweenerCore<Vector2, Vector2, VectorOptions> DOSizeDelta(this RectTransform target, Vector2 endVal
 331        {
 0332            TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.sizeDelta, x => target.sizeDelta = 
 0333            t.SetOptions(snapping).SetTarget(target);
 0334            return t;
 335        }
 336
 337        /// <summary>Punches a RectTransform's anchoredPosition towards the given direction and then back to the startin
 338        /// as if it was connected to the starting position via an elastic.
 339        /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 340        /// <param name="punch">The direction and strength of the punch (added to the RectTransform's current position)<
 341        /// <param name="duration">The duration of the tween</param>
 342        /// <param name="vibrato">Indicates how much will the punch vibrate</param>
 343        /// <param name="elasticity">Represents how much (0 to 1) the vector will go beyond the starting position when b
 344        /// 1 creates a full oscillation between the punch direction and the opposite direction,
 345        /// while 0 oscillates only between the punch and the start position</param>
 346        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 347        public static Tweener DOPunchAnchorPos(this RectTransform target, Vector2 punch, float duration, int vibrato = 1
 348        {
 0349            return DOTween.Punch(() => target.anchoredPosition, x => target.anchoredPosition = x, punch, duration, vibra
 350                .SetTarget(target).SetOptions(snapping);
 351        }
 352
 353        /// <summary>Shakes a RectTransform's anchoredPosition with the given values.
 354        /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 355        /// <param name="duration">The duration of the tween</param>
 356        /// <param name="strength">The shake strength</param>
 357        /// <param name="vibrato">Indicates how much will the shake vibrate</param>
 358        /// <param name="randomness">Indicates how much the shake will be random (0 to 180 - values higher than 90 kind 
 359        /// Setting it to 0 will shake along a single direction.</param>
 360        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 361        /// <param name="fadeOut">If TRUE the shake will automatically fadeOut smoothly within the tween's duration, oth
 362        public static Tweener DOShakeAnchorPos(this RectTransform target, float duration, float strength = 100, int vibr
 363        {
 0364            return DOTween.Shake(() => target.anchoredPosition, x => target.anchoredPosition = x, duration, strength, vi
 365                .SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetShake).SetOptions(snapping);
 366        }
 367        /// <summary>Shakes a RectTransform's anchoredPosition with the given values.
 368        /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 369        /// <param name="duration">The duration of the tween</param>
 370        /// <param name="strength">The shake strength on each axis</param>
 371        /// <param name="vibrato">Indicates how much will the shake vibrate</param>
 372        /// <param name="randomness">Indicates how much the shake will be random (0 to 180 - values higher than 90 kind 
 373        /// Setting it to 0 will shake along a single direction.</param>
 374        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 375        /// <param name="fadeOut">If TRUE the shake will automatically fadeOut smoothly within the tween's duration, oth
 376        public static Tweener DOShakeAnchorPos(this RectTransform target, float duration, Vector2 strength, int vibrato 
 377        {
 0378            return DOTween.Shake(() => target.anchoredPosition, x => target.anchoredPosition = x, duration, strength, vi
 379                .SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetShake).SetOptions(snapping);
 380        }
 381
 382        #region Special
 383
 384        /// <summary>Tweens a RectTransform's anchoredPosition to the given value, while also applying a jump effect alo
 385        /// Returns a Sequence instead of a Tweener.
 386        /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 387        /// <param name="endValue">The end value to reach</param>
 388        /// <param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final 
 389        /// <param name="numJumps">Total number of jumps</param>
 390        /// <param name="duration">The duration of the tween</param>
 391        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 392        public static Sequence DOJumpAnchorPos(this RectTransform target, Vector2 endValue, float jumpPower, int numJump
 393        {
 0394            if (numJumps < 1) numJumps = 1;
 0395            float startPosY = 0;
 0396            float offsetY = -1;
 0397            bool offsetYSet = false;
 398
 399            // Separate Y Tween so we can elaborate elapsedPercentage on that insted of on the Sequence
 400            // (in case users add a delay or other elements to the Sequence)
 0401            Sequence s = DOTween.Sequence();
 0402            Tween yTween = DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(0, ju
 403                .SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad).SetRelative()
 404                .SetLoops(numJumps * 2, LoopType.Yoyo)
 0405                .OnStart(()=> startPosY = target.anchoredPosition.y);
 0406            s.Append(DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(endValue.x,
 407                    .SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear)
 408                ).Join(yTween)
 409                .SetTarget(target).SetEase(DOTween.defaultEaseType);
 0410            s.OnUpdate(() => {
 0411                if (!offsetYSet) {
 0412                    offsetYSet = true;
 0413                    offsetY = s.isRelative ? endValue.y : endValue.y - startPosY;
 414                }
 0415                Vector2 pos = target.anchoredPosition;
 0416                pos.y += DOVirtual.EasedValue(0, offsetY, s.ElapsedDirectionalPercentage(), Ease.OutQuad);
 0417                target.anchoredPosition = pos;
 0418            });
 0419            return s;
 420        }
 421
 422        #endregion
 423
 424        #endregion
 425
 426        #region ScrollRect
 427
 428        /// <summary>Tweens a ScrollRect's horizontal/verticalNormalizedPosition to the given value.
 429        /// Also stores the ScrollRect as the tween's target so it can be used for filtered operations</summary>
 430        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 431        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 432        public static Tweener DONormalizedPos(this ScrollRect target, Vector2 endValue, float duration, bool snapping = 
 433        {
 0434            return DOTween.To(() => new Vector2(target.horizontalNormalizedPosition, target.verticalNormalizedPosition),
 435                x => {
 0436                    target.horizontalNormalizedPosition = x.x;
 0437                    target.verticalNormalizedPosition = x.y;
 0438                }, endValue, duration)
 439                .SetOptions(snapping).SetTarget(target);
 440        }
 441        /// <summary>Tweens a ScrollRect's horizontalNormalizedPosition to the given value.
 442        /// Also stores the ScrollRect as the tween's target so it can be used for filtered operations</summary>
 443        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 444        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 445        public static Tweener DOHorizontalNormalizedPos(this ScrollRect target, float endValue, float duration, bool sna
 446        {
 0447            return DOTween.To(() => target.horizontalNormalizedPosition, x => target.horizontalNormalizedPosition = x, e
 448                .SetOptions(snapping).SetTarget(target);
 449        }
 450        /// <summary>Tweens a ScrollRect's verticalNormalizedPosition to the given value.
 451        /// Also stores the ScrollRect as the tween's target so it can be used for filtered operations</summary>
 452        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 453        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 454        public static Tweener DOVerticalNormalizedPos(this ScrollRect target, float endValue, float duration, bool snapp
 455        {
 0456            return DOTween.To(() => target.verticalNormalizedPosition, x => target.verticalNormalizedPosition = x, endVa
 457                .SetOptions(snapping).SetTarget(target);
 458        }
 459
 460        #endregion
 461
 462        #region Slider
 463
 464        /// <summary>Tweens a Slider's value to the given value.
 465        /// Also stores the Slider as the tween's target so it can be used for filtered operations</summary>
 466        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 467        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 468        public static TweenerCore<float, float, FloatOptions> DOValue(this Slider target, float endValue, float duration
 469        {
 0470            TweenerCore<float, float, FloatOptions> t = DOTween.To(() => target.value, x => target.value = x, endValue, 
 0471            t.SetOptions(snapping).SetTarget(target);
 0472            return t;
 473        }
 474
 475        #endregion
 476
 477        #region Text
 478
 479        /// <summary>Tweens a Text's color to the given value.
 480        /// Also stores the Text as the tween's target so it can be used for filtered operations</summary>
 481        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 482        public static TweenerCore<Color, Color, ColorOptions> DOColor(this Text target, Color endValue, float duration)
 483        {
 0484            TweenerCore<Color, Color, ColorOptions> t = DOTween.To(() => target.color, x => target.color = x, endValue, 
 0485            t.SetTarget(target);
 0486            return t;
 487        }
 488
 489        /// <summary>
 490        /// Tweens a Text's text from one integer to another, with options for thousands separators
 491        /// </summary>
 492        /// <param name="fromValue">The value to start from</param>
 493        /// <param name="endValue">The end value to reach</param>
 494        /// <param name="duration">The duration of the tween</param>
 495        /// <param name="addThousandsSeparator">If TRUE (default) also adds thousands separators</param>
 496        /// <param name="culture">The <see cref="CultureInfo"/> to use (InvariantCulture if NULL)</param>
 497        public static TweenerCore<int, int, NoOptions> DOCounter(
 498            this Text target, int fromValue, int endValue, float duration, bool addThousandsSeparator = true, CultureInf
 499        ){
 0500            int v = fromValue;
 0501            CultureInfo cInfo = !addThousandsSeparator ? null : culture ?? CultureInfo.InvariantCulture;
 0502            TweenerCore<int, int, NoOptions> t = DOTween.To(() => v, x => {
 0503                v = x;
 0504                target.text = addThousandsSeparator
 505                    ? v.ToString("N0", cInfo)
 506                    : v.ToString();
 0507            }, endValue, duration);
 0508            t.SetTarget(target);
 0509            return t;
 510        }
 511
 512        /// <summary>Tweens a Text's alpha color to the given value.
 513        /// Also stores the Text as the tween's target so it can be used for filtered operations</summary>
 514        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param
 515        public static TweenerCore<Color, Color, ColorOptions> DOFade(this Text target, float endValue, float duration)
 516        {
 0517            TweenerCore<Color, Color, ColorOptions> t = DOTween.ToAlpha(() => target.color, x => target.color = x, endVa
 0518            t.SetTarget(target);
 0519            return t;
 520        }
 521
 522        /// <summary>Tweens a Text's text to the given value.
 523        /// Also stores the Text as the tween's target so it can be used for filtered operations</summary>
 524        /// <param name="endValue">The end string to tween to</param><param name="duration">The duration of the tween</p
 525        /// <param name="richTextEnabled">If TRUE (default), rich text will be interpreted correctly while animated,
 526        /// otherwise all tags will be considered as normal text</param>
 527        /// <param name="scrambleMode">The type of scramble mode to use, if any</param>
 528        /// <param name="scrambleChars">A string containing the characters to use for scrambling.
 529        /// Use as many characters as possible (minimum 10) because DOTween uses a fast scramble mode which gives better
 530        /// Leave it to NULL (default) to use default ones</param>
 531        public static TweenerCore<string, string, StringOptions> DOText(this Text target, string endValue, float duratio
 532        {
 0533            if (endValue == null) {
 0534                if (Debugger.logPriority > 0) Debugger.LogWarning("You can't pass a NULL string to DOText: an empty stri
 0535                endValue = "";
 536            }
 0537            TweenerCore<string, string, StringOptions> t = DOTween.To(() => target.text, x => target.text = x, endValue,
 0538            t.SetOptions(richTextEnabled, scrambleMode, scrambleChars)
 539                .SetTarget(target);
 0540            return t;
 541        }
 542
 543        #endregion
 544
 545        #region Blendables
 546
 547        #region Graphic
 548
 549        /// <summary>Tweens a Graphic's color to the given value,
 550        /// in a way that allows other DOBlendableColor tweens to work together on the same target,
 551        /// instead than fight each other as multiple DOColor would do.
 552        /// Also stores the Graphic as the tween's target so it can be used for filtered operations</summary>
 553        /// <param name="endValue">The value to tween to</param><param name="duration">The duration of the tween</param>
 554        public static Tweener DOBlendableColor(this Graphic target, Color endValue, float duration)
 555        {
 0556            endValue = endValue - target.color;
 0557            Color to = new Color(0, 0, 0, 0);
 0558            return DOTween.To(() => to, x => {
 0559                Color diff = x - to;
 0560                to = x;
 0561                target.color += diff;
 0562            }, endValue, duration)
 563                .Blendable().SetTarget(target);
 564        }
 565
 566        #endregion
 567
 568        #region Image
 569
 570        /// <summary>Tweens a Image's color to the given value,
 571        /// in a way that allows other DOBlendableColor tweens to work together on the same target,
 572        /// instead than fight each other as multiple DOColor would do.
 573        /// Also stores the Image as the tween's target so it can be used for filtered operations</summary>
 574        /// <param name="endValue">The value to tween to</param><param name="duration">The duration of the tween</param>
 575        public static Tweener DOBlendableColor(this Image target, Color endValue, float duration)
 576        {
 0577            endValue = endValue - target.color;
 0578            Color to = new Color(0, 0, 0, 0);
 0579            return DOTween.To(() => to, x => {
 0580                Color diff = x - to;
 0581                to = x;
 0582                target.color += diff;
 0583            }, endValue, duration)
 584                .Blendable().SetTarget(target);
 585        }
 586
 587        #endregion
 588
 589        #region Text
 590
 591        /// <summary>Tweens a Text's color BY the given value,
 592        /// in a way that allows other DOBlendableColor tweens to work together on the same target,
 593        /// instead than fight each other as multiple DOColor would do.
 594        /// Also stores the Text as the tween's target so it can be used for filtered operations</summary>
 595        /// <param name="endValue">The value to tween to</param><param name="duration">The duration of the tween</param>
 596        public static Tweener DOBlendableColor(this Text target, Color endValue, float duration)
 597        {
 0598            endValue = endValue - target.color;
 0599            Color to = new Color(0, 0, 0, 0);
 0600            return DOTween.To(() => to, x => {
 0601                Color diff = x - to;
 0602                to = x;
 0603                target.color += diff;
 0604            }, endValue, duration)
 605                .Blendable().SetTarget(target);
 606        }
 607
 608        #endregion
 609
 610        #endregion
 611
 612        #region Shapes
 613
 614        /// <summary>Tweens a RectTransform's anchoredPosition so that it draws a circle around the given center.
 615        /// Also stores the RectTransform as the tween's target so it can be used for filtered operations.<para/>
 616        /// IMPORTANT: SetFrom(value) requires a <see cref="Vector2"/> instead of a float, where the X property represen
 617        /// <param name="center">Circle-center/pivot around which to rotate (in UI anchoredPosition coordinates)</param>
 618        /// <param name="endValueDegrees">The end value degrees to reach (to rotate counter-clockwise pass a negative va
 619        /// <param name="duration">The duration of the tween</param>
 620        /// <param name="relativeCenter">If TRUE the <see cref="center"/> coordinates will be considered as relative to 
 621        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 622        public static TweenerCore<Vector2, Vector2, CircleOptions> DOShapeCircle(
 623            this RectTransform target, Vector2 center, float endValueDegrees, float duration, bool relativeCenter = fals
 624        )
 625        {
 0626            TweenerCore<Vector2, Vector2, CircleOptions> t = DOTween.To(
 0627                CirclePlugin.Get(), () => target.anchoredPosition, x => target.anchoredPosition = x, center, duration
 628            );
 0629            t.SetOptions(endValueDegrees, relativeCenter, snapping).SetTarget(target);
 0630            return t;
 631        }
 632
 633        #endregion
 634
 635        #endregion
 636
 637        // █████████████████████████████████████████████████████████████████████████████████████████████████████████████
 638        // ███ INTERNAL CLASSES ████████████████████████████████████████████████████████████████████████████████████████
 639        // █████████████████████████████████████████████████████████████████████████████████████████████████████████████
 640
 641        public static class Utils
 642        {
 643            /// <summary>
 644            /// Converts the anchoredPosition of the first RectTransform to the second RectTransform,
 645            /// taking into consideration offset, anchors and pivot, and returns the new anchoredPosition
 646            /// </summary>
 647            public static Vector2 SwitchToRectTransform(RectTransform from, RectTransform to)
 648            {
 649                Vector2 localPoint;
 0650                Vector2 fromPivotDerivedOffset = new Vector2(from.rect.width * 0.5f + from.rect.xMin, from.rect.height *
 0651                Vector2 screenP = RectTransformUtility.WorldToScreenPoint(null, from.position);
 0652                screenP += fromPivotDerivedOffset;
 0653                RectTransformUtility.ScreenPointToLocalPointInRectangle(to, screenP, null, out localPoint);
 0654                Vector2 pivotDerivedOffset = new Vector2(to.rect.width * 0.5f + to.rect.xMin, to.rect.height * 0.5f + to
 0655                return to.anchoredPosition + localPoint - pivotDerivedOffset;
 656            }
 657        }
 658  }
 659}
 660#endif

Methods/Properties

DOFade(UnityEngine.CanvasGroup, System.Single, System.Single)
DOColor(UnityEngine.UI.Graphic, UnityEngine.Color, System.Single)
DOFade(UnityEngine.UI.Graphic, System.Single, System.Single)
DOColor(UnityEngine.UI.Image, UnityEngine.Color, System.Single)
DOFade(UnityEngine.UI.Image, System.Single, System.Single)
DOFillAmount(UnityEngine.UI.Image, System.Single, System.Single)
DOGradientColor(UnityEngine.UI.Image, UnityEngine.Gradient, System.Single)
DOFlexibleSize(UnityEngine.UI.LayoutElement, UnityEngine.Vector2, System.Single, System.Boolean)
DOMinSize(UnityEngine.UI.LayoutElement, UnityEngine.Vector2, System.Single, System.Boolean)
DOPreferredSize(UnityEngine.UI.LayoutElement, UnityEngine.Vector2, System.Single, System.Boolean)
DOColor(UnityEngine.UI.Outline, UnityEngine.Color, System.Single)
DOFade(UnityEngine.UI.Outline, System.Single, System.Single)
DOScale(UnityEngine.UI.Outline, UnityEngine.Vector2, System.Single)
DOAnchorPos(UnityEngine.RectTransform, UnityEngine.Vector2, System.Single, System.Boolean)
DOAnchorPosX(UnityEngine.RectTransform, System.Single, System.Single, System.Boolean)
DOAnchorPosY(UnityEngine.RectTransform, System.Single, System.Single, System.Boolean)
DOAnchorPos3D(UnityEngine.RectTransform, UnityEngine.Vector3, System.Single, System.Boolean)
DOAnchorPos3DX(UnityEngine.RectTransform, System.Single, System.Single, System.Boolean)
DOAnchorPos3DY(UnityEngine.RectTransform, System.Single, System.Single, System.Boolean)
DOAnchorPos3DZ(UnityEngine.RectTransform, System.Single, System.Single, System.Boolean)
DOAnchorMax(UnityEngine.RectTransform, UnityEngine.Vector2, System.Single, System.Boolean)
DOAnchorMin(UnityEngine.RectTransform, UnityEngine.Vector2, System.Single, System.Boolean)
DOPivot(UnityEngine.RectTransform, UnityEngine.Vector2, System.Single)
DOPivotX(UnityEngine.RectTransform, System.Single, System.Single)
DOPivotY(UnityEngine.RectTransform, System.Single, System.Single)
DOSizeDelta(UnityEngine.RectTransform, UnityEngine.Vector2, System.Single, System.Boolean)
DOPunchAnchorPos(UnityEngine.RectTransform, UnityEngine.Vector2, System.Single, System.Int32, System.Single, System.Boolean)
DOShakeAnchorPos(UnityEngine.RectTransform, System.Single, System.Single, System.Int32, System.Single, System.Boolean, System.Boolean)
DOShakeAnchorPos(UnityEngine.RectTransform, System.Single, UnityEngine.Vector2, System.Int32, System.Single, System.Boolean, System.Boolean)
DOJumpAnchorPos(UnityEngine.RectTransform, UnityEngine.Vector2, System.Single, System.Int32, System.Single, System.Boolean)
DONormalizedPos(UnityEngine.UI.ScrollRect, UnityEngine.Vector2, System.Single, System.Boolean)
DOHorizontalNormalizedPos(UnityEngine.UI.ScrollRect, System.Single, System.Single, System.Boolean)
DOVerticalNormalizedPos(UnityEngine.UI.ScrollRect, System.Single, System.Single, System.Boolean)
DOValue(UnityEngine.UI.Slider, System.Single, System.Single, System.Boolean)
DOColor(UnityEngine.UI.Text, UnityEngine.Color, System.Single)
DOCounter(UnityEngine.UI.Text, System.Int32, System.Int32, System.Single, System.Boolean, System.Globalization.CultureInfo)
DOFade(UnityEngine.UI.Text, System.Single, System.Single)
DOText(UnityEngine.UI.Text, System.String, System.Single, System.Boolean, DG.Tweening.ScrambleMode, System.String)
DOBlendableColor(UnityEngine.UI.Graphic, UnityEngine.Color, System.Single)
DOBlendableColor(UnityEngine.UI.Image, UnityEngine.Color, System.Single)
DOBlendableColor(UnityEngine.UI.Text, UnityEngine.Color, System.Single)
DOShapeCircle(UnityEngine.RectTransform, UnityEngine.Vector2, System.Single, System.Single, System.Boolean, System.Boolean)
SwitchToRectTransform(UnityEngine.RectTransform, UnityEngine.RectTransform)