diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.XML b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.XML index 7046bfe..1345284 100644 --- a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.XML +++ b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.XML @@ -273,6 +273,9 @@ INTERNAL: do not use + + INTERNAL: do not use + INTERNAL: do not use @@ -2383,6 +2386,24 @@ then immediately sends the target to the previously set endValue. If TRUE the FROM value will be calculated as relative to the current one + + Changes a TO tween into a FROM tween: sets the tween's starting value to the given one + and eventually sets the tween's target to that value immediately. + Value to start from + If TRUE sets the target to from value immediately, otherwise waits for the tween to start + + + Changes a TO tween into a FROM tween: sets the tween's starting value to the given one + and eventually sets the tween's target to that value immediately. + Alpha value to start from (in case of Fade tweens) + If TRUE sets the target to from value immediately, otherwise waits for the tween to start + + + Changes a TO tween into a FROM tween: sets the tween's starting value to the given one + and eventually sets the tween's target to that value immediately. + Value to start from (in case of Vector tweens that act on a single coordinate or scale tweens) + If TRUE sets the target to from value immediately, otherwise waits for the tween to start + Sets a delayed startup for the tween. Has no effect on Sequences or if the tween has already started diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll index d6d8103..3a0f645 100644 Binary files a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll and b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll differ diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll.mdb b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll.mdb index c80812c..f0bbf1f 100644 Binary files a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll.mdb and b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll.mdb differ diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll b/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll index 19a8b05..887b1cf 100644 Binary files a/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll and b/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll differ diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll.mdb b/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll.mdb index 3181ee1..90e94a5 100644 Binary files a/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll.mdb and b/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll.mdb differ diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenUpgradeManager.dll b/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenUpgradeManager.dll index dd09104..56f348e 100644 Binary files a/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenUpgradeManager.dll and b/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenUpgradeManager.dll differ diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenUpgradeManager.dll.mdb b/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenUpgradeManager.dll.mdb index f8c7588..4ec07df 100644 Binary files a/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenUpgradeManager.dll.mdb and b/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenUpgradeManager.dll.mdb differ diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModuleAudio.cs b/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModuleAudio.cs index c342c02..c195b6c 100644 --- a/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModuleAudio.cs +++ b/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModuleAudio.cs @@ -3,6 +3,8 @@ #if true // MODULE_MARKER using System; +using DG.Tweening.Core; +using DG.Tweening.Plugins.Options; using UnityEngine; #if UNITY_5 || UNITY_2017_1_OR_NEWER using UnityEngine.Audio; // Required for AudioMixer @@ -20,19 +22,23 @@ namespace DG.Tweening /// Tweens an AudioSource's volume to the given value. /// Also stores the AudioSource as the tween's target so it can be used for filtered operations /// The end value to reach (0 to 1)The duration of the tween - public static Tweener DOFade(this AudioSource target, float endValue, float duration) + public static TweenerCore DOFade(this AudioSource target, float endValue, float duration) { if (endValue < 0) endValue = 0; else if (endValue > 1) endValue = 1; - return DOTween.To(() => target.volume, x => target.volume = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.volume, x => target.volume = x, endValue, duration); + t.SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween - public static Tweener DOPitch(this AudioSource target, float endValue, float duration) + public static TweenerCore DOPitch(this AudioSource target, float endValue, float duration) { - return DOTween.To(() => target.pitch, x => target.pitch = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.pitch, x => target.pitch = x, endValue, duration); + t.SetTarget(target); + return t; } #endregion @@ -45,14 +51,15 @@ namespace DG.Tweening /// Note that you need to manually expose a float in an AudioMixerGroup in order to be able to tween it from an AudioMixer. /// Name given to the exposed float to set /// The end value to reachThe duration of the tween - public static Tweener DOSetFloat(this AudioMixer target, string floatName, float endValue, float duration) + public static TweenerCore DOSetFloat(this AudioMixer target, string floatName, float endValue, float duration) { - return DOTween.To(()=> { + TweenerCore t = DOTween.To(()=> { float currVal; target.GetFloat(floatName, out currVal); return currVal; - }, x=> target.SetFloat(floatName, x), endValue, duration) - .SetTarget(target); + }, x=> target.SetFloat(floatName, x), endValue, duration); + t.SetTarget(target); + return t; } #region Operation Shortcuts diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModulePhysics.cs b/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModulePhysics.cs index 2a85cc6..a1a1cb9 100644 --- a/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModulePhysics.cs +++ b/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModulePhysics.cs @@ -23,47 +23,51 @@ namespace DG.Tweening /// Also stores the rigidbody as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMove(this Rigidbody target, Vector3 endValue, float duration, bool snapping = false) + public static TweenerCore DOMove(this Rigidbody target, Vector3 endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.position, target.MovePosition, endValue, duration) - .SetOptions(snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.position, target.MovePosition, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// Tweens a Rigidbody's X position to the given value. /// Also stores the rigidbody as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMoveX(this Rigidbody target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOMoveX(this Rigidbody target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.position, target.MovePosition, new Vector3(endValue, 0, 0), duration) - .SetOptions(AxisConstraint.X, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.position, target.MovePosition, new Vector3(endValue, 0, 0), duration); + t.SetOptions(AxisConstraint.X, snapping).SetTarget(target); + return t; } /// Tweens a Rigidbody's Y position to the given value. /// Also stores the rigidbody as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMoveY(this Rigidbody target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOMoveY(this Rigidbody target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.position, target.MovePosition, new Vector3(0, endValue, 0), duration) - .SetOptions(AxisConstraint.Y, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.position, target.MovePosition, new Vector3(0, endValue, 0), duration); + t.SetOptions(AxisConstraint.Y, snapping).SetTarget(target); + return t; } /// Tweens a Rigidbody's Z position to the given value. /// Also stores the rigidbody as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMoveZ(this Rigidbody target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOMoveZ(this Rigidbody target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.position, target.MovePosition, new Vector3(0, 0, endValue), duration) - .SetOptions(AxisConstraint.Z, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.position, target.MovePosition, new Vector3(0, 0, endValue), duration); + t.SetOptions(AxisConstraint.Z, snapping).SetTarget(target); + return t; } /// Tweens a Rigidbody's rotation to the given value. /// Also stores the rigidbody as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// Rotation mode - public static Tweener DORotate(this Rigidbody target, Vector3 endValue, float duration, RotateMode mode = RotateMode.Fast) + public static TweenerCore DORotate(this Rigidbody target, Vector3 endValue, float duration, RotateMode mode = RotateMode.Fast) { TweenerCore t = DOTween.To(() => target.rotation, target.MoveRotation, endValue, duration); t.SetTarget(target); @@ -76,7 +80,7 @@ namespace DG.Tweening /// The position to look atThe duration of the tween /// Eventual axis constraint for the rotation /// The vector that defines in which direction up is (default: Vector3.up) - public static Tweener DOLookAt(this Rigidbody target, Vector3 towards, float duration, AxisConstraint axisConstraint = AxisConstraint.None, Vector3? up = null) + public static TweenerCore DOLookAt(this Rigidbody target, Vector3 towards, float duration, AxisConstraint axisConstraint = AxisConstraint.None, Vector3? up = null) { TweenerCore t = DOTween.To(() => target.rotation, target.MoveRotation, towards, duration) .SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetLookAt); diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModulePhysics2D.cs b/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModulePhysics2D.cs index f4e2aa2..f40a7d0 100644 --- a/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModulePhysics2D.cs +++ b/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModulePhysics2D.cs @@ -3,6 +3,8 @@ #if true && (UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER) // MODULE_MARKER using System; +using DG.Tweening.Core; +using DG.Tweening.Plugins.Options; using UnityEngine; #pragma warning disable 1591 @@ -18,39 +20,43 @@ namespace DG.Tweening /// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMove(this Rigidbody2D target, Vector2 endValue, float duration, bool snapping = false) + public static TweenerCore DOMove(this Rigidbody2D target, Vector2 endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.position, target.MovePosition, endValue, duration) - .SetOptions(snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.position, target.MovePosition, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMoveX(this Rigidbody2D target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOMoveX(this Rigidbody2D target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.position, target.MovePosition, new Vector2(endValue, 0), duration) - .SetOptions(AxisConstraint.X, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.position, target.MovePosition, new Vector2(endValue, 0), duration); + t.SetOptions(AxisConstraint.X, snapping).SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMoveY(this Rigidbody2D target, float endValue, float duration, bool snapping = false) + public static TweenerCore 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); + TweenerCore t = DOTween.To(() => target.position, target.MovePosition, new Vector2(0, endValue), duration); + t.SetOptions(AxisConstraint.Y, snapping).SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween - public static Tweener DORotate(this Rigidbody2D target, float endValue, float duration) + public static TweenerCore DORotate(this Rigidbody2D target, float endValue, float duration) { - return DOTween.To(() => target.rotation, target.MoveRotation, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.To(() => target.rotation, target.MoveRotation, endValue, duration); + t.SetTarget(target); + return t; } #region Special diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModuleSprite.cs b/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModuleSprite.cs index 12e07aa..9450ca5 100644 --- a/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModuleSprite.cs +++ b/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModuleSprite.cs @@ -5,6 +5,7 @@ using System; using UnityEngine; using DG.Tweening.Core; +using DG.Tweening.Plugins.Options; #pragma warning disable 1591 namespace DG.Tweening @@ -18,18 +19,21 @@ namespace DG.Tweening /// Tweens a SpriteRenderer's color to the given value. /// Also stores the spriteRenderer as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOColor(this SpriteRenderer target, Color endValue, float duration) + public static TweenerCore DOColor(this SpriteRenderer target, Color endValue, float duration) { - return DOTween.To(() => target.color, x => target.color = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.color, x => target.color = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Material's alpha color to the given value. /// Also stores the spriteRenderer as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOFade(this SpriteRenderer target, float endValue, float duration) + public static TweenerCore DOFade(this SpriteRenderer target, float endValue, float duration) { - return DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a SpriteRenderer's color using the given gradient diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModuleUI.cs b/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModuleUI.cs index df2b42c..072c02c 100644 --- a/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModuleUI.cs +++ b/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModuleUI.cs @@ -7,6 +7,7 @@ using UnityEngine; using UnityEngine.UI; using DG.Tweening.Core; using DG.Tweening.Core.Enums; +using DG.Tweening.Plugins.Options; #pragma warning disable 1591 namespace DG.Tweening @@ -20,10 +21,11 @@ namespace DG.Tweening /// 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 /// The end value to reachThe duration of the tween - public static Tweener DOFade(this CanvasGroup target, float endValue, float duration) + public static TweenerCore DOFade(this CanvasGroup target, float endValue, float duration) { - return DOTween.To(() => target.alpha, x => target.alpha = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.To(() => target.alpha, x => target.alpha = x, endValue, duration); + t.SetTarget(target); + return t; } #endregion @@ -33,18 +35,21 @@ namespace DG.Tweening /// Tweens an Graphic's color to the given value. /// Also stores the image as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOColor(this Graphic target, Color endValue, float duration) + public static TweenerCore DOColor(this Graphic target, Color endValue, float duration) { - return DOTween.To(() => target.color, x => target.color = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.color, x => target.color = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens an Graphic's alpha color to the given value. /// Also stores the image as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOFade(this Graphic target, float endValue, float duration) + public static TweenerCore DOFade(this Graphic target, float endValue, float duration) { - return DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration); + t.SetTarget(target); + return t; } #endregion @@ -54,29 +59,33 @@ namespace DG.Tweening /// 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 /// The end value to reachThe duration of the tween - public static Tweener DOColor(this Image target, Color endValue, float duration) + public static TweenerCore DOColor(this Image target, Color endValue, float duration) { - return DOTween.To(() => target.color, x => target.color = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.color, x => target.color = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens an Image's alpha color to the given value. /// Also stores the image as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOFade(this Image target, float endValue, float duration) + public static TweenerCore DOFade(this Image target, float endValue, float duration) { - return DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens an Image's fillAmount to the given value. /// Also stores the image as the tween's target so it can be used for filtered operations /// The end value to reach (0 to 1)The duration of the tween - public static Tweener DOFillAmount(this Image target, float endValue, float duration) + public static TweenerCore DOFillAmount(this Image target, float endValue, float duration) { if (endValue > 1) endValue = 1; else if (endValue < 0) endValue = 0; - return DOTween.To(() => target.fillAmount, x => target.fillAmount = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.To(() => target.fillAmount, x => target.fillAmount = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens an Image's colors using the given gradient @@ -110,39 +119,42 @@ namespace DG.Tweening /// Also stores the LayoutElement as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOFlexibleSize(this LayoutElement target, Vector2 endValue, float duration, bool snapping = false) + public static TweenerCore DOFlexibleSize(this LayoutElement target, Vector2 endValue, float duration, bool snapping = false) { - return DOTween.To(() => new Vector2(target.flexibleWidth, target.flexibleHeight), x => { + TweenerCore t = DOTween.To(() => new Vector2(target.flexibleWidth, target.flexibleHeight), x => { target.flexibleWidth = x.x; target.flexibleHeight = x.y; - }, endValue, duration) - .SetOptions(snapping).SetTarget(target); + }, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// Tweens an LayoutElement's minWidth/Height to the given value. /// Also stores the LayoutElement as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMinSize(this LayoutElement target, Vector2 endValue, float duration, bool snapping = false) + public static TweenerCore DOMinSize(this LayoutElement target, Vector2 endValue, float duration, bool snapping = false) { - return DOTween.To(() => new Vector2(target.minWidth, target.minHeight), x => { + TweenerCore t = DOTween.To(() => new Vector2(target.minWidth, target.minHeight), x => { target.minWidth = x.x; target.minHeight = x.y; - }, endValue, duration) - .SetOptions(snapping).SetTarget(target); + }, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// Tweens an LayoutElement's preferredWidth/Height to the given value. /// Also stores the LayoutElement as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOPreferredSize(this LayoutElement target, Vector2 endValue, float duration, bool snapping = false) + public static TweenerCore DOPreferredSize(this LayoutElement target, Vector2 endValue, float duration, bool snapping = false) { - return DOTween.To(() => new Vector2(target.preferredWidth, target.preferredHeight), x => { + TweenerCore t = DOTween.To(() => new Vector2(target.preferredWidth, target.preferredHeight), x => { target.preferredWidth = x.x; target.preferredHeight = x.y; - }, endValue, duration) - .SetOptions(snapping).SetTarget(target); + }, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } #endregion @@ -152,27 +164,31 @@ namespace DG.Tweening /// Tweens a Outline's effectColor to the given value. /// Also stores the Outline as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOColor(this Outline target, Color endValue, float duration) + public static TweenerCore DOColor(this Outline target, Color endValue, float duration) { - return DOTween.To(() => target.effectColor, x => target.effectColor = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.effectColor, x => target.effectColor = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Outline's effectColor alpha to the given value. /// Also stores the Outline as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOFade(this Outline target, float endValue, float duration) + public static TweenerCore DOFade(this Outline target, float endValue, float duration) { - return DOTween.ToAlpha(() => target.effectColor, x => target.effectColor = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.ToAlpha(() => target.effectColor, x => target.effectColor = x, endValue, duration); + t.SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween - public static Tweener DOScale(this Outline target, Vector2 endValue, float duration) + public static TweenerCore DOScale(this Outline target, Vector2 endValue, float duration) { - return DOTween.To(() => target.effectDistance, x => target.effectDistance = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.To(() => target.effectDistance, x => target.effectDistance = x, endValue, duration); + t.SetTarget(target); + return t; } #endregion @@ -183,120 +199,133 @@ namespace DG.Tweening /// Also stores the RectTransform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOAnchorPos(this RectTransform target, Vector2 endValue, float duration, bool snapping = false) + public static TweenerCore DOAnchorPos(this RectTransform target, Vector2 endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, endValue, duration) - .SetOptions(snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// Tweens a RectTransform's anchoredPosition X to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOAnchorPosX(this RectTransform target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOAnchorPosX(this RectTransform target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(endValue, 0), duration) - .SetOptions(AxisConstraint.X, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(endValue, 0), duration); + t.SetOptions(AxisConstraint.X, snapping).SetTarget(target); + return t; } /// Tweens a RectTransform's anchoredPosition Y to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOAnchorPosY(this RectTransform target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOAnchorPosY(this RectTransform target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(0, endValue), duration) - .SetOptions(AxisConstraint.Y, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(0, endValue), duration); + t.SetOptions(AxisConstraint.Y, snapping).SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOAnchorPos3D(this RectTransform target, Vector3 endValue, float duration, bool snapping = false) + public static TweenerCore 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); + TweenerCore t = DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// Tweens a RectTransform's anchoredPosition3D X to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOAnchorPos3DX(this RectTransform target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOAnchorPos3DX(this RectTransform target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, new Vector3(endValue, 0, 0), duration) - .SetOptions(AxisConstraint.X, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, new Vector3(endValue, 0, 0), duration); + t.SetOptions(AxisConstraint.X, snapping).SetTarget(target); + return t; } /// Tweens a RectTransform's anchoredPosition3D Y to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOAnchorPos3DY(this RectTransform target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOAnchorPos3DY(this RectTransform target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, new Vector3(0, endValue, 0), duration) - .SetOptions(AxisConstraint.Y, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, new Vector3(0, endValue, 0), duration); + t.SetOptions(AxisConstraint.Y, snapping).SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOAnchorPos3DZ(this RectTransform target, float endValue, float duration, bool snapping = false) + public static TweenerCore 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); + TweenerCore t = DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, new Vector3(0, 0, endValue), duration); + t.SetOptions(AxisConstraint.Z, snapping).SetTarget(target); + return t; } /// Tweens a RectTransform's anchorMax to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOAnchorMax(this RectTransform target, Vector2 endValue, float duration, bool snapping = false) + public static TweenerCore DOAnchorMax(this RectTransform target, Vector2 endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.anchorMax, x => target.anchorMax = x, endValue, duration) - .SetOptions(snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.anchorMax, x => target.anchorMax = x, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// Tweens a RectTransform's anchorMin to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOAnchorMin(this RectTransform target, Vector2 endValue, float duration, bool snapping = false) + public static TweenerCore DOAnchorMin(this RectTransform target, Vector2 endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.anchorMin, x => target.anchorMin = x, endValue, duration) - .SetOptions(snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.anchorMin, x => target.anchorMin = x, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween - public static Tweener DOPivot(this RectTransform target, Vector2 endValue, float duration) + public static TweenerCore DOPivot(this RectTransform target, Vector2 endValue, float duration) { - return DOTween.To(() => target.pivot, x => target.pivot = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.To(() => target.pivot, x => target.pivot = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a RectTransform's pivot X to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOPivotX(this RectTransform target, float endValue, float duration) + public static TweenerCore DOPivotX(this RectTransform target, float endValue, float duration) { - return DOTween.To(() => target.pivot, x => target.pivot = x, new Vector2(endValue, 0), duration) - .SetOptions(AxisConstraint.X).SetTarget(target); + TweenerCore t = DOTween.To(() => target.pivot, x => target.pivot = x, new Vector2(endValue, 0), duration); + t.SetOptions(AxisConstraint.X).SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween - public static Tweener DOPivotY(this RectTransform target, float endValue, float duration) + public static TweenerCore 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); + TweenerCore t = DOTween.To(() => target.pivot, x => target.pivot = x, new Vector2(0, endValue), duration); + t.SetOptions(AxisConstraint.Y).SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOSizeDelta(this RectTransform target, Vector2 endValue, float duration, bool snapping = false) + public static TweenerCore 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); + TweenerCore t = DOTween.To(() => target.sizeDelta, x => target.sizeDelta = x, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// Punches a RectTransform's anchoredPosition towards the given direction and then back to the starting one @@ -430,10 +459,11 @@ namespace DG.Tweening /// Also stores the Slider as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOValue(this Slider target, float endValue, float duration, bool snapping = false) + public static TweenerCore 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); + TweenerCore t = DOTween.To(() => target.value, x => target.value = x, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } #endregion @@ -443,18 +473,21 @@ namespace DG.Tweening /// Tweens a Text's color to the given value. /// Also stores the Text as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOColor(this Text target, Color endValue, float duration) + public static TweenerCore DOColor(this Text target, Color endValue, float duration) { - return DOTween.To(() => target.color, x => target.color = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.color, x => target.color = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Text's alpha color to the given value. /// Also stores the Text as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOFade(this Text target, float endValue, float duration) + public static TweenerCore DOFade(this Text target, float endValue, float duration) { - return DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Text's text to the given value. @@ -466,11 +499,12 @@ namespace DG.Tweening /// 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 - public static Tweener DOText(this Text target, string endValue, float duration, bool richTextEnabled = true, ScrambleMode scrambleMode = ScrambleMode.None, string scrambleChars = null) + public static TweenerCore 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) + TweenerCore t = DOTween.To(() => target.text, x => target.text = x, endValue, duration); + t.SetOptions(richTextEnabled, scrambleMode, scrambleChars) .SetTarget(target); + return t; } #endregion diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModuleUnityVersion.cs b/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModuleUnityVersion.cs index caede5e..176ecae 100644 --- a/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModuleUnityVersion.cs +++ b/UnityTests.Unity5/Assets/Demigiant/DOTween/Modules/DOTweenModuleUnityVersion.cs @@ -4,6 +4,7 @@ using System; using UnityEngine; using DG.Tweening.Core; +using DG.Tweening.Plugins.Options; #pragma warning disable 1591 namespace DG.Tweening @@ -178,13 +179,15 @@ namespace DG.Tweening /// The end value to reach /// The ID of the material property to tween (also called nameID in Unity's manual) /// The duration of the tween - public static Tweener DOOffset(this Material target, Vector2 endValue, int propertyID, float duration) + public static TweenerCore DOOffset(this Material target, Vector2 endValue, int propertyID, float duration) { if (!target.HasProperty(propertyID)) { if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID); return null; } - return DOTween.To(() => target.GetTextureOffset(propertyID), x => target.SetTextureOffset(propertyID, x), endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.GetTextureOffset(propertyID), x => target.SetTextureOffset(propertyID, x), endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Material's named texture scale property with the given ID to the given value. @@ -192,13 +195,15 @@ namespace DG.Tweening /// The end value to reach /// The ID of the material property to tween (also called nameID in Unity's manual) /// The duration of the tween - public static Tweener DOTiling(this Material target, Vector2 endValue, int propertyID, float duration) + public static TweenerCore DOTiling(this Material target, Vector2 endValue, int propertyID, float duration) { if (!target.HasProperty(propertyID)) { if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID); return null; } - return DOTween.To(() => target.GetTextureScale(propertyID), x => target.SetTextureScale(propertyID, x), endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.GetTextureScale(propertyID), x => target.SetTextureScale(propertyID, x), endValue, duration); + t.SetTarget(target); + return t; } #endregion diff --git a/UnityTests.Unity5/Assets/Demigiant/DemiLib/Core/Editor/Imgs/whiteSquare.png.meta b/UnityTests.Unity5/Assets/Demigiant/DemiLib/Core/Editor/Imgs/whiteSquare.png.meta index 64c38ed..02f9661 100644 --- a/UnityTests.Unity5/Assets/Demigiant/DemiLib/Core/Editor/Imgs/whiteSquare.png.meta +++ b/UnityTests.Unity5/Assets/Demigiant/DemiLib/Core/Editor/Imgs/whiteSquare.png.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 guid: d3e15b806a8368742ba6f10e794d7b76 -timeCreated: 1551364502 +timeCreated: 1551372288 licenseType: Pro TextureImporter: fileIDToRecycleName: {} diff --git a/UnityTests.Unity5/Assets/_DOTween Examples/CustomPlugin Example/CustomRangePlugin.cs b/UnityTests.Unity5/Assets/_DOTween Examples/CustomPlugin Example/CustomRangePlugin.cs index 4bf6454..f1bf62d 100644 --- a/UnityTests.Unity5/Assets/_DOTween Examples/CustomPlugin Example/CustomRangePlugin.cs +++ b/UnityTests.Unity5/Assets/_DOTween Examples/CustomPlugin Example/CustomRangePlugin.cs @@ -25,6 +25,12 @@ public class CustomRangePlugin : ABSTweenPlugin t, CustomRange fromValue, bool setImmediately) + { + t.startValue = fromValue; + if (setImmediately) t.setter(fromValue); + } + // Used by special plugins, just let it return the given value public override CustomRange ConvertToStartValue(TweenerCore t, CustomRange value) { diff --git a/UnityTests.Unity5/Assets/_DOTween Examples/CustomPlugin Example/old (scrapped).meta b/UnityTests.Unity5/Assets/_DOTween Examples/CustomPlugin Example/old (scrapped).meta deleted file mode 100644 index 4f7ba02..0000000 --- a/UnityTests.Unity5/Assets/_DOTween Examples/CustomPlugin Example/old (scrapped).meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 0e19028f4214f3241b7878d71060677c -folderAsset: yes -timeCreated: 1444384496 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/UnityTests.Unity5/Assets/_DOTween Examples/CustomPlugin Example/old (scrapped)/PlugCustomPlugin.cs b/UnityTests.Unity5/Assets/_DOTween Examples/CustomPlugin Example/old (scrapped)/PlugCustomPlugin.cs deleted file mode 100644 index 6a736d2..0000000 --- a/UnityTests.Unity5/Assets/_DOTween Examples/CustomPlugin Example/old (scrapped)/PlugCustomPlugin.cs +++ /dev/null @@ -1,74 +0,0 @@ -using DG.Tweening; -using DG.Tweening.Core; -using DG.Tweening.Core.Easing; -using DG.Tweening.Core.Enums; -using DG.Tweening.Plugins.Core; -using DG.Tweening.Plugins.Options; -using System; -using UnityEngine; - -public struct PlugCustomPlugin : IPlugSetter -{ - readonly Vector3 _endValue; - readonly DOGetter _getter; - readonly DOSetter _setter; - - public PlugCustomPlugin(DOGetter getter, DOSetter setter, float endValue) - { - _getter = getter; - _setter = setter; - _endValue = new Vector3(endValue, 0, 0); - } - - public DOGetter Getter() { return _getter; } - public DOSetter Setter() { return _setter; } - public Vector3 EndValue() { return _endValue; } - public NoOptions GetOptions() { return new NoOptions(); } -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// ||| CLASS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -public class CustomPlugin : ABSTweenPlugin -{ - public override void Reset(TweenerCore t) {} - - public override void SetFrom(TweenerCore t, bool isRelative) - { - Vector3 prevEndVal = t.endValue; - t.endValue = t.getter(); - t.startValue = isRelative ? t.endValue + prevEndVal : prevEndVal; - t.setter(t.startValue); - } - - public override Vector3 ConvertToStartValue(TweenerCore t, Vector3 value) - { - return value; - } - - public override void SetRelativeEndValue(TweenerCore t) - { - t.endValue = t.startValue + t.changeValue; - } - - public override void SetChangeValue(TweenerCore t) - { - t.changeValue = t.endValue - t.startValue; - } - - public override float GetSpeedBasedDuration(NoOptions options, float unitsXSecond, Vector3 changeValue) - { - float res = changeValue.magnitude / unitsXSecond; - if (res < 0) res = -res; - return res; - } - - public override void EvaluateAndApply(NoOptions options, Tween t, bool isRelative, DOGetter getter, DOSetter setter, float elapsed, Vector3 startValue, Vector3 changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) - { - Vector3 res = getter(); - float easeVal = EaseManager.Evaluate(t, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod); - res.x = startValue.x + changeValue.x * easeVal; - setter(res); - } -} \ No newline at end of file diff --git a/UnityTests.Unity5/Assets/_Tests/DOCompletePerformance.cs b/UnityTests.Unity5/Assets/_Tests/DOCompletePerformance.cs index 1daf89c..c452cb0 100644 --- a/UnityTests.Unity5/Assets/_Tests/DOCompletePerformance.cs +++ b/UnityTests.Unity5/Assets/_Tests/DOCompletePerformance.cs @@ -14,7 +14,7 @@ public class DOCompletePerformance : BrainBase Debug.Log(Time.realtimeSinceStartup + " :: Create " + totTweens + " tweens on " + (tweenFloatValue ? "float" : "transform")); for (int i = 0; i < totTweens; ++i) { Tween t = tweenFloatValue - ? DOTween.To(()=> floatValue, x=> floatValue = x, 2, 10) + ? (Tween)DOTween.To(()=> floatValue, x=> floatValue = x, 2, 10) : target.DOMoveX(2, 10); if (!byTarget) t.SetId("myId"); else if (tweenFloatValue) t.SetTarget(target); diff --git a/UnityTests.Unity5/Assets/_Tests/FromValue.cs b/UnityTests.Unity5/Assets/_Tests/FromValue.cs new file mode 100644 index 0000000..a4562bb --- /dev/null +++ b/UnityTests.Unity5/Assets/_Tests/FromValue.cs @@ -0,0 +1,19 @@ +using System.Collections; +using System.Collections.Generic; +using DG.Tweening; +using UnityEngine; + +public class FromValue : BrainBase +{ + public GameObject cube; + + IEnumerator Start() + { + Tween t = cube.transform.DOMoveX(2, 2); + yield return t.WaitForCompletion(); + + t = cube.transform.DOMoveX(3, 2).From(10); + cube.GetComponent().material.DOFade(1, 2).From(0.5f); + yield return t.WaitForCompletion(); + } +} \ No newline at end of file diff --git a/UnityTests.Unity5/Assets/_DOTween Examples/CustomPlugin Example/old (scrapped)/PlugCustomPlugin.cs.meta b/UnityTests.Unity5/Assets/_Tests/FromValue.cs.meta similarity index 53% rename from UnityTests.Unity5/Assets/_DOTween Examples/CustomPlugin Example/old (scrapped)/PlugCustomPlugin.cs.meta rename to UnityTests.Unity5/Assets/_Tests/FromValue.cs.meta index 58744b5..a2c9348 100644 --- a/UnityTests.Unity5/Assets/_DOTween Examples/CustomPlugin Example/old (scrapped)/PlugCustomPlugin.cs.meta +++ b/UnityTests.Unity5/Assets/_Tests/FromValue.cs.meta @@ -1,8 +1,12 @@ fileFormatVersion: 2 -guid: af2497efc5625554ba3ad4d45cdad868 +guid: 7f8e935c8c281c14fa14d16a06261fd3 +timeCreated: 1551447234 +licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityTests.Unity5/Assets/_Tests/FromValue.unity b/UnityTests.Unity5/Assets/_Tests/FromValue.unity new file mode 100644 index 0000000..946f45f Binary files /dev/null and b/UnityTests.Unity5/Assets/_Tests/FromValue.unity differ diff --git a/UnityTests.Unity5/Assets/_Tests/FromValue.unity.meta b/UnityTests.Unity5/Assets/_Tests/FromValue.unity.meta new file mode 100644 index 0000000..9e6260b --- /dev/null +++ b/UnityTests.Unity5/Assets/_Tests/FromValue.unity.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: a0295fa208ad901478c17ea6714f74d6 +DefaultImporter: + userData: diff --git a/_DOTween.Assembly/DOTween/Core/TweenerCore.cs b/_DOTween.Assembly/DOTween/Core/TweenerCore.cs index d2b8dad..f40576e 100644 --- a/_DOTween.Assembly/DOTween/Core/TweenerCore.cs +++ b/_DOTween.Assembly/DOTween/Core/TweenerCore.cs @@ -124,6 +124,17 @@ namespace DG.Tweening.Core hasManuallySetStartValue = true; return this; } + // Sets From tweens in an alternate way where you can set the start value directly + // (instead of setting it from the endValue). + // Plugins that don't support From: + // - Vector3ArrayPlugin + // - Pro > PathPlugin, SpiralPlugin + internal Tweener SetFrom(T2 fromValue, bool setImmediately) + { + tweenPlugin.SetFrom(this, fromValue, setImmediately); + hasManuallySetStartValue = true; + return this; + } // _tweenPlugin is not reset since it's useful to keep it as a reference internal sealed override void Reset() diff --git a/_DOTween.Assembly/DOTween/CustomPlugins/PureQuaternionPlugin.cs b/_DOTween.Assembly/DOTween/CustomPlugins/PureQuaternionPlugin.cs index 12f7974..815774f 100644 --- a/_DOTween.Assembly/DOTween/CustomPlugins/PureQuaternionPlugin.cs +++ b/_DOTween.Assembly/DOTween/CustomPlugins/PureQuaternionPlugin.cs @@ -44,6 +44,12 @@ namespace DG.Tweening.CustomPlugins t.startValue = isRelative ? t.endValue * prevEndVal : prevEndVal; t.setter(t.startValue); } + /// INTERNAL: do not use + public override void SetFrom(TweenerCore t, Quaternion fromValue, bool setImmediately) + { + t.startValue = fromValue; + if (setImmediately) t.setter(fromValue); + } /// INTERNAL: do not use public override Quaternion ConvertToStartValue(TweenerCore t, Quaternion value) diff --git a/_DOTween.Assembly/DOTween/DOTween.cs b/_DOTween.Assembly/DOTween/DOTween.cs index 68d631c..0c34377 100644 --- a/_DOTween.Assembly/DOTween/DOTween.cs +++ b/_DOTween.Assembly/DOTween/DOTween.cs @@ -32,7 +32,7 @@ namespace DG.Tweening public class DOTween { /// DOTween's version - public static readonly string Version = "1.2.211"; // Last version before modules: 1.1.755 + public static readonly string Version = "1.2.220"; // Last version before modules: 1.1.755 /////////////////////////////////////////////// // Options //////////////////////////////////// @@ -312,7 +312,7 @@ namespace DG.Tweening /// A setter for the field or property to tween /// Example usage with lambda:x=> myProperty = x /// The end value to reachThe tween's duration - public static Tweener To(DOGetter getter, DOSetter setter, int endValue,float duration) + public static TweenerCore To(DOGetter getter, DOSetter setter, int endValue,float duration) { return ApplyTo(getter, setter, endValue, duration); } /// Tweens a property or field to the given value using default plugins /// A getter for the field or property to tween. @@ -320,7 +320,7 @@ namespace DG.Tweening /// A setter for the field or property to tween /// Example usage with lambda:x=> myProperty = x /// The end value to reachThe tween's duration - public static Tweener To(DOGetter getter, DOSetter setter, uint endValue, float duration) + public static TweenerCore To(DOGetter getter, DOSetter setter, uint endValue, float duration) { return ApplyTo(getter, setter, endValue, duration); } /// Tweens a property or field to the given value using default plugins /// A getter for the field or property to tween. @@ -328,7 +328,7 @@ namespace DG.Tweening /// A setter for the field or property to tween /// Example usage with lambda:x=> myProperty = x /// The end value to reachThe tween's duration - public static Tweener To(DOGetter getter, DOSetter setter, long endValue, float duration) + public static TweenerCore To(DOGetter getter, DOSetter setter, long endValue, float duration) { return ApplyTo(getter, setter, endValue, duration); } /// Tweens a property or field to the given value using default plugins /// A getter for the field or property to tween. @@ -336,7 +336,7 @@ namespace DG.Tweening /// A setter for the field or property to tween /// Example usage with lambda:x=> myProperty = x /// The end value to reachThe tween's duration - public static Tweener To(DOGetter getter, DOSetter setter, ulong endValue, float duration) + public static TweenerCore To(DOGetter getter, DOSetter setter, ulong endValue, float duration) { return ApplyTo(getter, setter, endValue, duration); } /// Tweens a property or field to the given value using default plugins /// A getter for the field or property to tween. @@ -431,14 +431,19 @@ namespace DG.Tweening t.plugOptions.axisConstraint = axisConstraint; return t; } + /// Tweens only the alpha of a Color to the given value using default plugins /// A getter for the field or property to tween. /// Example usage with lambda:()=> myProperty /// A setter for the field or property to tween /// Example usage with lambda:x=> myProperty = x /// The end value to reachThe tween's duration - public static Tweener ToAlpha(DOGetter getter, DOSetter setter, float endValue, float duration) - { return ApplyTo(getter, setter, new Color(0, 0, 0, endValue), duration).SetOptions(true); } + public static TweenerCore ToAlpha(DOGetter getter, DOSetter setter, float endValue, float duration) + { + TweenerCore t = ApplyTo(getter, setter, new Color(0, 0, 0, endValue), duration); + t.SetOptions(true); + return t; + } #endregion diff --git a/_DOTween.Assembly/DOTween/Plugins/Color2Plugin.cs b/_DOTween.Assembly/DOTween/Plugins/Color2Plugin.cs index 7920866..7853ca1 100644 --- a/_DOTween.Assembly/DOTween/Plugins/Color2Plugin.cs +++ b/_DOTween.Assembly/DOTween/Plugins/Color2Plugin.cs @@ -29,6 +29,19 @@ namespace DG.Tweening.Plugins } t.setter(to); } + public override void SetFrom(TweenerCore t, Color2 fromValue, bool setImmediately) + { + t.startValue = fromValue; + if (setImmediately) { + Color2 to = fromValue; + if (t.plugOptions.alphaOnly) { + to = t.getter(); + to.ca.a = fromValue.ca.a; + to.cb.a = fromValue.cb.a; + } + t.setter(to); + } + } public override Color2 ConvertToStartValue(TweenerCore t, Color2 value) { diff --git a/_DOTween.Assembly/DOTween/Plugins/ColorPlugin.cs b/_DOTween.Assembly/DOTween/Plugins/ColorPlugin.cs index ef897ef..a94fb96 100644 --- a/_DOTween.Assembly/DOTween/Plugins/ColorPlugin.cs +++ b/_DOTween.Assembly/DOTween/Plugins/ColorPlugin.cs @@ -29,6 +29,18 @@ namespace DG.Tweening.Plugins else to.a = t.startValue.a; t.setter(to); } + public override void SetFrom(TweenerCore t, Color fromValue, bool setImmediately) + { + t.startValue = fromValue; + if (setImmediately) { + Color to = fromValue; + if (t.plugOptions.alphaOnly) { + to = t.getter(); + to.a = fromValue.a; + } + t.setter(to); + } + } public override Color ConvertToStartValue(TweenerCore t, Color value) { diff --git a/_DOTween.Assembly/DOTween/Plugins/Core/ABSTweenPlugin.cs b/_DOTween.Assembly/DOTween/Plugins/Core/ABSTweenPlugin.cs index 4b71379..15bf22f 100644 --- a/_DOTween.Assembly/DOTween/Plugins/Core/ABSTweenPlugin.cs +++ b/_DOTween.Assembly/DOTween/Plugins/Core/ABSTweenPlugin.cs @@ -16,6 +16,7 @@ namespace DG.Tweening.Plugins.Core { public abstract void Reset(TweenerCore t); // Resets specific TweenerCore stuff, not the plugin itself public abstract void SetFrom(TweenerCore t, bool isRelative); + public abstract void SetFrom(TweenerCore t, T2 fromValue, bool setImmediately); public abstract T2 ConvertToStartValue(TweenerCore t, T1 value); public abstract void SetRelativeEndValue(TweenerCore t); public abstract void SetChangeValue(TweenerCore t); diff --git a/_DOTween.Assembly/DOTween/Plugins/DoublePlugin.cs b/_DOTween.Assembly/DOTween/Plugins/DoublePlugin.cs index 508042d..273902a 100644 --- a/_DOTween.Assembly/DOTween/Plugins/DoublePlugin.cs +++ b/_DOTween.Assembly/DOTween/Plugins/DoublePlugin.cs @@ -24,6 +24,11 @@ namespace DG.Tweening.Plugins t.startValue = isRelative ? t.endValue + prevEndVal : prevEndVal; t.setter(t.startValue); } + public override void SetFrom(TweenerCore t, double fromValue, bool setImmediately) + { + t.startValue = fromValue; + if (setImmediately) t.setter(fromValue); + } public override double ConvertToStartValue(TweenerCore t, double value) { diff --git a/_DOTween.Assembly/DOTween/Plugins/FloatPlugin.cs b/_DOTween.Assembly/DOTween/Plugins/FloatPlugin.cs index 86c55e7..ab430e2 100644 --- a/_DOTween.Assembly/DOTween/Plugins/FloatPlugin.cs +++ b/_DOTween.Assembly/DOTween/Plugins/FloatPlugin.cs @@ -26,6 +26,11 @@ namespace DG.Tweening.Plugins t.startValue = isRelative ? t.endValue + prevEndVal : prevEndVal; t.setter(!t.plugOptions.snapping ? t.startValue : (float)Math.Round(t.startValue)); } + public override void SetFrom(TweenerCore t, float fromValue, bool setImmediately) + { + t.startValue = fromValue; + if (setImmediately) t.setter(!t.plugOptions.snapping ? fromValue : (float)Math.Round(fromValue)); + } public override float ConvertToStartValue(TweenerCore t, float value) { diff --git a/_DOTween.Assembly/DOTween/Plugins/IntPlugin.cs b/_DOTween.Assembly/DOTween/Plugins/IntPlugin.cs index 644ad21..5e39319 100644 --- a/_DOTween.Assembly/DOTween/Plugins/IntPlugin.cs +++ b/_DOTween.Assembly/DOTween/Plugins/IntPlugin.cs @@ -25,6 +25,11 @@ namespace DG.Tweening.Plugins t.startValue = isRelative ? t.endValue + prevEndVal : prevEndVal; t.setter(t.startValue); } + public override void SetFrom(TweenerCore t, int fromValue, bool setImmediately) + { + t.startValue = fromValue; + if (setImmediately) t.setter(fromValue); + } public override int ConvertToStartValue(TweenerCore t, int value) { diff --git a/_DOTween.Assembly/DOTween/Plugins/LongPlugin.cs b/_DOTween.Assembly/DOTween/Plugins/LongPlugin.cs index 49f1f5e..14c9326 100644 --- a/_DOTween.Assembly/DOTween/Plugins/LongPlugin.cs +++ b/_DOTween.Assembly/DOTween/Plugins/LongPlugin.cs @@ -22,6 +22,11 @@ namespace DG.Tweening.Plugins t.startValue = isRelative ? t.endValue + prevEndVal : prevEndVal; t.setter(t.startValue); } + public override void SetFrom(TweenerCore t, long fromValue, bool setImmediately) + { + t.startValue = fromValue; + if (setImmediately) t.setter(fromValue); + } public override long ConvertToStartValue(TweenerCore t, long value) { diff --git a/_DOTween.Assembly/DOTween/Plugins/PathPlugin.cs b/_DOTween.Assembly/DOTween/Plugins/PathPlugin.cs index 6b53a96..1b86594 100644 --- a/_DOTween.Assembly/DOTween/Plugins/PathPlugin.cs +++ b/_DOTween.Assembly/DOTween/Plugins/PathPlugin.cs @@ -29,6 +29,7 @@ namespace DG.Tweening.Plugins } public override void SetFrom(TweenerCore t, bool isRelative) {} + public override void SetFrom(TweenerCore t, Path fromValue, bool setImmediately) {} public static ABSTweenPlugin Get() { diff --git a/_DOTween.Assembly/DOTween/Plugins/QuaternionPlugin.cs b/_DOTween.Assembly/DOTween/Plugins/QuaternionPlugin.cs index 0837b22..6e8afb7 100644 --- a/_DOTween.Assembly/DOTween/Plugins/QuaternionPlugin.cs +++ b/_DOTween.Assembly/DOTween/Plugins/QuaternionPlugin.cs @@ -38,6 +38,11 @@ namespace DG.Tweening.Plugins } t.setter(Quaternion.Euler(t.startValue)); } + public override void SetFrom(TweenerCore t, Vector3 fromValue, bool setImmediately) + { + t.startValue = fromValue; + if (setImmediately) t.setter(Quaternion.Euler(fromValue)); + } public override Vector3 ConvertToStartValue(TweenerCore t, Quaternion value) { diff --git a/_DOTween.Assembly/DOTween/Plugins/RectOffsetPlugin.cs b/_DOTween.Assembly/DOTween/Plugins/RectOffsetPlugin.cs index 8587dd4..08da1a7 100644 --- a/_DOTween.Assembly/DOTween/Plugins/RectOffsetPlugin.cs +++ b/_DOTween.Assembly/DOTween/Plugins/RectOffsetPlugin.cs @@ -39,6 +39,11 @@ namespace DG.Tweening.Plugins } t.setter(t.startValue); } + public override void SetFrom(TweenerCore t, RectOffset fromValue, bool setImmediately) + { + t.startValue = fromValue; + if (setImmediately) t.setter(fromValue); + } public override RectOffset ConvertToStartValue(TweenerCore t, RectOffset value) { diff --git a/_DOTween.Assembly/DOTween/Plugins/RectPlugin.cs b/_DOTween.Assembly/DOTween/Plugins/RectPlugin.cs index 6998db1..60d2006 100644 --- a/_DOTween.Assembly/DOTween/Plugins/RectPlugin.cs +++ b/_DOTween.Assembly/DOTween/Plugins/RectPlugin.cs @@ -39,6 +39,20 @@ namespace DG.Tweening.Plugins } t.setter(to); } + public override void SetFrom(TweenerCore t, Rect fromValue, bool setImmediately) + { + t.startValue = fromValue; + if (setImmediately) { + Rect to = fromValue; + if (t.plugOptions.snapping) { + to.x = (float)Math.Round(to.x); + to.y = (float)Math.Round(to.y); + to.width = (float)Math.Round(to.width); + to.height = (float)Math.Round(to.height); + } + t.setter(to); + } + } public override Rect ConvertToStartValue(TweenerCore t, Rect value) { diff --git a/_DOTween.Assembly/DOTween/Plugins/StringPlugin.cs b/_DOTween.Assembly/DOTween/Plugins/StringPlugin.cs index d27c301..b7dba4d 100644 --- a/_DOTween.Assembly/DOTween/Plugins/StringPlugin.cs +++ b/_DOTween.Assembly/DOTween/Plugins/StringPlugin.cs @@ -32,6 +32,11 @@ namespace DG.Tweening.Plugins t.startValue = prevEndVal; t.setter(t.startValue); } + public override void SetFrom(TweenerCore t, string fromValue, bool setImmediately) + { + t.startValue = fromValue; + if (setImmediately) t.setter(fromValue); + } public override void Reset(TweenerCore t) { diff --git a/_DOTween.Assembly/DOTween/Plugins/UintPlugin.cs b/_DOTween.Assembly/DOTween/Plugins/UintPlugin.cs index 2f314bb..5273efb 100644 --- a/_DOTween.Assembly/DOTween/Plugins/UintPlugin.cs +++ b/_DOTween.Assembly/DOTween/Plugins/UintPlugin.cs @@ -26,6 +26,11 @@ namespace DG.Tweening.Plugins t.startValue = isRelative ? t.endValue + prevEndVal : prevEndVal; t.setter(t.startValue); } + public override void SetFrom(TweenerCore t, uint fromValue, bool setImmediately) + { + t.startValue = fromValue; + if (setImmediately) t.setter(fromValue); + } public override uint ConvertToStartValue(TweenerCore t, uint value) { diff --git a/_DOTween.Assembly/DOTween/Plugins/UlongPlugin.cs b/_DOTween.Assembly/DOTween/Plugins/UlongPlugin.cs index e8d9a39..42432d9 100644 --- a/_DOTween.Assembly/DOTween/Plugins/UlongPlugin.cs +++ b/_DOTween.Assembly/DOTween/Plugins/UlongPlugin.cs @@ -23,6 +23,11 @@ namespace DG.Tweening.Plugins t.startValue = isRelative ? t.endValue + prevEndVal : prevEndVal; t.setter(t.startValue); } + public override void SetFrom(TweenerCore t, ulong fromValue, bool setImmediately) + { + t.startValue = fromValue; + if (setImmediately) t.setter(fromValue); + } public override ulong ConvertToStartValue(TweenerCore t, ulong value) { diff --git a/_DOTween.Assembly/DOTween/Plugins/Vector2Plugin.cs b/_DOTween.Assembly/DOTween/Plugins/Vector2Plugin.cs index 5117220..e3f7963 100644 --- a/_DOTween.Assembly/DOTween/Plugins/Vector2Plugin.cs +++ b/_DOTween.Assembly/DOTween/Plugins/Vector2Plugin.cs @@ -43,6 +43,31 @@ namespace DG.Tweening.Plugins } t.setter(to); } + public override void SetFrom(TweenerCore t, Vector2 fromValue, bool setImmediately) + { + t.startValue = fromValue; + if (setImmediately) { + Vector2 to; + switch (t.plugOptions.axisConstraint) { + case AxisConstraint.X: + to = t.getter(); + to.x = fromValue.x; + break; + case AxisConstraint.Y: + to = t.getter(); + to.y = fromValue.y; + break; + default: + to = fromValue; + break; + } + if (t.plugOptions.snapping) { + to.x = (float)Math.Round(to.x); + to.y = (float)Math.Round(to.y); + } + t.setter(to); + } + } public override Vector2 ConvertToStartValue(TweenerCore t, Vector2 value) { diff --git a/_DOTween.Assembly/DOTween/Plugins/Vector3ArrayPlugin.cs b/_DOTween.Assembly/DOTween/Plugins/Vector3ArrayPlugin.cs index 07fd672..82c62e9 100644 --- a/_DOTween.Assembly/DOTween/Plugins/Vector3ArrayPlugin.cs +++ b/_DOTween.Assembly/DOTween/Plugins/Vector3ArrayPlugin.cs @@ -26,6 +26,7 @@ namespace DG.Tweening.Plugins } public override void SetFrom(TweenerCore t, bool isRelative) {} + public override void SetFrom(TweenerCore t, Vector3[] fromValue, bool setImmediately) {} public override Vector3[] ConvertToStartValue(TweenerCore t, Vector3 value) { diff --git a/_DOTween.Assembly/DOTween/Plugins/Vector3Plugin.cs b/_DOTween.Assembly/DOTween/Plugins/Vector3Plugin.cs index 96565b9..f95c237 100644 --- a/_DOTween.Assembly/DOTween/Plugins/Vector3Plugin.cs +++ b/_DOTween.Assembly/DOTween/Plugins/Vector3Plugin.cs @@ -47,6 +47,36 @@ namespace DG.Tweening.Plugins } t.setter(to); } + public override void SetFrom(TweenerCore t, Vector3 fromValue, bool setImmediately) + { + t.startValue = fromValue; + if (setImmediately) { + Vector3 to; + switch (t.plugOptions.axisConstraint) { + case AxisConstraint.X: + to = t.getter(); + to.x = fromValue.x; + break; + case AxisConstraint.Y: + to = t.getter(); + to.y = fromValue.y; + break; + case AxisConstraint.Z: + to = t.getter(); + to.z = fromValue.z; + break; + default: + to = fromValue; + break; + } + if (t.plugOptions.snapping) { + to.x = (float)Math.Round(to.x); + to.y = (float)Math.Round(to.y); + to.z = (float)Math.Round(to.z); + } + t.setter(to); + } + } public override Vector3 ConvertToStartValue(TweenerCore t, Vector3 value) { diff --git a/_DOTween.Assembly/DOTween/Plugins/Vector4Plugin.cs b/_DOTween.Assembly/DOTween/Plugins/Vector4Plugin.cs index 58450d5..5f4156a 100644 --- a/_DOTween.Assembly/DOTween/Plugins/Vector4Plugin.cs +++ b/_DOTween.Assembly/DOTween/Plugins/Vector4Plugin.cs @@ -52,6 +52,42 @@ namespace DG.Tweening.Plugins t.setter(to); } + public override void SetFrom(TweenerCore t, Vector4 fromValue, bool setImmediately) + { + t.startValue = fromValue; + if (setImmediately) { + Vector4 to; + switch (t.plugOptions.axisConstraint) { + case AxisConstraint.X: + to = t.getter(); + to.x = fromValue.x; + break; + case AxisConstraint.Y: + to = t.getter(); + to.y = fromValue.y; + break; + case AxisConstraint.Z: + to = t.getter(); + to.z = fromValue.z; + break; + case AxisConstraint.W: + to = t.getter(); + to.w = fromValue.w; + break; + default: + to = fromValue; + break; + } + if (t.plugOptions.snapping) { + to.x = (float)Math.Round(to.x); + to.y = (float)Math.Round(to.y); + to.z = (float)Math.Round(to.z); + to.w = (float)Math.Round(to.w); + } + t.setter(to); + } + } + public override Vector4 ConvertToStartValue(TweenerCore t, Vector4 value) { return value; diff --git a/_DOTween.Assembly/DOTween/ShortcutExtensions.cs b/_DOTween.Assembly/DOTween/ShortcutExtensions.cs index d078bb9..6bbc575 100644 --- a/_DOTween.Assembly/DOTween/ShortcutExtensions.cs +++ b/_DOTween.Assembly/DOTween/ShortcutExtensions.cs @@ -36,65 +36,81 @@ namespace DG.Tweening /// Tweens a Camera's aspect to the given value. /// Also stores the camera as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOAspect(this Camera target, float endValue, float duration) + public static TweenerCore DOAspect(this Camera target, float endValue, float duration) { - return DOTween.To(() => target.aspect, x => target.aspect = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.aspect, x => target.aspect = x, endValue, duration); + t.SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween - public static Tweener DOColor(this Camera target, Color endValue, float duration) + public static TweenerCore DOColor(this Camera target, Color endValue, float duration) { - return DOTween.To(() => target.backgroundColor, x => target.backgroundColor = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.backgroundColor, x => target.backgroundColor = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Camera's farClipPlane to the given value. /// Also stores the camera as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOFarClipPlane(this Camera target, float endValue, float duration) + public static TweenerCore DOFarClipPlane(this Camera target, float endValue, float duration) { - return DOTween.To(() => target.farClipPlane, x => target.farClipPlane = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.farClipPlane, x => target.farClipPlane = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Camera's fieldOfView to the given value. /// Also stores the camera as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOFieldOfView(this Camera target, float endValue, float duration) + public static TweenerCore DOFieldOfView(this Camera target, float endValue, float duration) { - return DOTween.To(() => target.fieldOfView, x => target.fieldOfView = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.fieldOfView, x => target.fieldOfView = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Camera's nearClipPlane to the given value. /// Also stores the camera as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DONearClipPlane(this Camera target, float endValue, float duration) + public static TweenerCore DONearClipPlane(this Camera target, float endValue, float duration) { - return DOTween.To(() => target.nearClipPlane, x => target.nearClipPlane = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.nearClipPlane, x => target.nearClipPlane = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Camera's orthographicSize to the given value. /// Also stores the camera as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOOrthoSize(this Camera target, float endValue, float duration) + public static TweenerCore DOOrthoSize(this Camera target, float endValue, float duration) { - return DOTween.To(() => target.orthographicSize, x => target.orthographicSize = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.orthographicSize, x => target.orthographicSize = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Camera's pixelRect to the given value. /// Also stores the camera as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOPixelRect(this Camera target, Rect endValue, float duration) + public static TweenerCore DOPixelRect(this Camera target, Rect endValue, float duration) { - return DOTween.To(() => target.pixelRect, x => target.pixelRect = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.pixelRect, x => target.pixelRect = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Camera's rect to the given value. /// Also stores the camera as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DORect(this Camera target, Rect endValue, float duration) + public static TweenerCore DORect(this Camera target, Rect endValue, float duration) { - return DOTween.To(() => target.rect, x => target.rect = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.rect, x => target.rect = x, endValue, duration); + t.SetTarget(target); + return t; } /// Shakes a Camera's localPosition along its relative X Y axes with the given values. @@ -174,25 +190,31 @@ namespace DG.Tweening /// Tweens a Light's color to the given value. /// Also stores the light as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOColor(this Light target, Color endValue, float duration) + public static TweenerCore DOColor(this Light target, Color endValue, float duration) { - return DOTween.To(() => target.color, x => target.color = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.color, x => target.color = x, endValue, duration); + t.SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween - public static Tweener DOIntensity(this Light target, float endValue, float duration) + public static TweenerCore DOIntensity(this Light target, float endValue, float duration) { - return DOTween.To(() => target.intensity, x => target.intensity = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.intensity, x => target.intensity = x, endValue, duration); + t.SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween - public static Tweener DOShadowStrength(this Light target, float endValue, float duration) + public static TweenerCore DOShadowStrength(this Light target, float endValue, float duration) { - return DOTween.To(() => target.shadowStrength, x => target.shadowStrength = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.shadowStrength, x => target.shadowStrength = x, endValue, duration); + t.SetTarget(target); + return t; } #endregion @@ -217,45 +239,52 @@ namespace DG.Tweening /// Tweens a Material's color to the given value. /// Also stores the material as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOColor(this Material target, Color endValue, float duration) + public static TweenerCore DOColor(this Material target, Color endValue, float duration) { - return DOTween.To(() => target.color, x => target.color = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.color, x => target.color = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Material's named color property to the given value. /// Also stores the material as the tween's target so it can be used for filtered operations /// The end value to reach /// The name of the material property to tween (like _Tint or _SpecColor) /// The duration of the tween - public static Tweener DOColor(this Material target, Color endValue, string property, float duration) + public static TweenerCore DOColor(this Material target, Color endValue, string property, float duration) { if (!target.HasProperty(property)) { if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(property); return null; } - return DOTween.To(() => target.GetColor(property), x => target.SetColor(property, x), endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.GetColor(property), x => target.SetColor(property, x), endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Material's named color property with the given ID to the given value. /// Also stores the material as the tween's target so it can be used for filtered operations /// The end value to reach /// The ID of the material property to tween (also called nameID in Unity's manual) /// The duration of the tween - public static Tweener DOColor(this Material target, Color endValue, int propertyID, float duration) + public static TweenerCore DOColor(this Material target, Color endValue, int propertyID, float duration) { if (!target.HasProperty(propertyID)) { if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID); return null; } - return DOTween.To(() => target.GetColor(propertyID), x => target.SetColor(propertyID, x), endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.GetColor(propertyID), x => target.SetColor(propertyID, x), endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Material's alpha color to the given value /// (will have no effect unless your material supports transparency). /// Also stores the material as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOFade(this Material target, float endValue, float duration) + public static TweenerCore DOFade(this Material target, float endValue, float duration) { - return DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Material's alpha color to the given value /// (will have no effect unless your material supports transparency). @@ -263,13 +292,15 @@ namespace DG.Tweening /// The end value to reach /// The name of the material property to tween (like _Tint or _SpecColor) /// The duration of the tween - public static Tweener DOFade(this Material target, float endValue, string property, float duration) + public static TweenerCore DOFade(this Material target, float endValue, string property, float duration) { if (!target.HasProperty(property)) { if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(property); return null; } - return DOTween.ToAlpha(() => target.GetColor(property), x => target.SetColor(property, x), endValue, duration).SetTarget(target); + TweenerCore t = DOTween.ToAlpha(() => target.GetColor(property), x => target.SetColor(property, x), endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Material's alpha color with the given ID to the given value /// (will have no effect unless your material supports transparency). @@ -277,13 +308,15 @@ namespace DG.Tweening /// The end value to reach /// The ID of the material property to tween (also called nameID in Unity's manual) /// The duration of the tween - public static Tweener DOFade(this Material target, float endValue, int propertyID, float duration) + public static TweenerCore DOFade(this Material target, float endValue, int propertyID, float duration) { if (!target.HasProperty(propertyID)) { if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID); return null; } - return DOTween.ToAlpha(() => target.GetColor(propertyID), x => target.SetColor(propertyID, x), endValue, duration).SetTarget(target); + TweenerCore t = DOTween.ToAlpha(() => target.GetColor(propertyID), x => target.SetColor(propertyID, x), endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Material's named float property to the given value. @@ -291,70 +324,82 @@ namespace DG.Tweening /// The end value to reach /// The name of the material property to tween /// The duration of the tween - public static Tweener DOFloat(this Material target, float endValue, string property, float duration) + public static TweenerCore DOFloat(this Material target, float endValue, string property, float duration) { if (!target.HasProperty(property)) { if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(property); return null; } - return DOTween.To(() => target.GetFloat(property), x => target.SetFloat(property, x), endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.GetFloat(property), x => target.SetFloat(property, x), endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Material's named float property with the given ID to the given value. /// Also stores the material as the tween's target so it can be used for filtered operations /// The end value to reach /// The ID of the material property to tween (also called nameID in Unity's manual) /// The duration of the tween - public static Tweener DOFloat(this Material target, float endValue, int propertyID, float duration) + public static TweenerCore DOFloat(this Material target, float endValue, int propertyID, float duration) { if (!target.HasProperty(propertyID)) { if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID); return null; } - return DOTween.To(() => target.GetFloat(propertyID), x => target.SetFloat(propertyID, x), endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.GetFloat(propertyID), x => target.SetFloat(propertyID, x), endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Material's texture offset to the given value. /// Also stores the material as the tween's target so it can be used for filtered operations /// The end value to reach /// The duration of the tween - public static Tweener DOOffset(this Material target, Vector2 endValue, float duration) + public static TweenerCore DOOffset(this Material target, Vector2 endValue, float duration) { - return DOTween.To(() => target.mainTextureOffset, x => target.mainTextureOffset = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.mainTextureOffset, x => target.mainTextureOffset = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Material's named texture offset property to the given value. /// Also stores the material as the tween's target so it can be used for filtered operations /// The end value to reach /// The name of the material property to tween /// The duration of the tween - public static Tweener DOOffset(this Material target, Vector2 endValue, string property, float duration) + public static TweenerCore DOOffset(this Material target, Vector2 endValue, string property, float duration) { if (!target.HasProperty(property)) { if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(property); return null; } - return DOTween.To(() => target.GetTextureOffset(property), x => target.SetTextureOffset(property, x), endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.GetTextureOffset(property), x => target.SetTextureOffset(property, x), endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Material's texture scale to the given value. /// Also stores the material as the tween's target so it can be used for filtered operations /// The end value to reach /// The duration of the tween - public static Tweener DOTiling(this Material target, Vector2 endValue, float duration) + public static TweenerCore DOTiling(this Material target, Vector2 endValue, float duration) { - return DOTween.To(() => target.mainTextureScale, x => target.mainTextureScale = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.mainTextureScale, x => target.mainTextureScale = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Material's named texture scale property to the given value. /// Also stores the material as the tween's target so it can be used for filtered operations /// The end value to reach /// The name of the material property to tween /// The duration of the tween - public static Tweener DOTiling(this Material target, Vector2 endValue, string property, float duration) + public static TweenerCore DOTiling(this Material target, Vector2 endValue, string property, float duration) { if (!target.HasProperty(property)) { if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(property); return null; } - return DOTween.To(() => target.GetTextureScale(property), x => target.SetTextureScale(property, x), endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.GetTextureScale(property), x => target.SetTextureScale(property, x), endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Material's named Vector property to the given value. @@ -362,26 +407,30 @@ namespace DG.Tweening /// The end value to reach /// The name of the material property to tween /// The duration of the tween - public static Tweener DOVector(this Material target, Vector4 endValue, string property, float duration) + public static TweenerCore DOVector(this Material target, Vector4 endValue, string property, float duration) { if (!target.HasProperty(property)) { if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(property); return null; } - return DOTween.To(() => target.GetVector(property), x => target.SetVector(property, x), endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.GetVector(property), x => target.SetVector(property, x), endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Material's named Vector property with the given ID to the given value. /// Also stores the material as the tween's target so it can be used for filtered operations /// The end value to reach /// The ID of the material property to tween (also called nameID in Unity's manual) /// The duration of the tween - public static Tweener DOVector(this Material target, Vector4 endValue, int propertyID, float duration) + public static TweenerCore DOVector(this Material target, Vector4 endValue, int propertyID, float duration) { if (!target.HasProperty(propertyID)) { if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID); return null; } - return DOTween.To(() => target.GetVector(propertyID), x => target.SetVector(propertyID, x), endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.GetVector(propertyID), x => target.SetVector(propertyID, x), endValue, duration); + t.SetTarget(target); + return t; } #endregion @@ -409,10 +458,11 @@ namespace DG.Tweening /// 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 /// The end value to reachThe duration of the tween - public static Tweener DOTime(this TrailRenderer target, float endValue, float duration) + public static TweenerCore DOTime(this TrailRenderer target, float endValue, float duration) { - return DOTween.To(() => target.time, x => target.time = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.To(() => target.time, x => target.time = x, endValue, duration); + t.SetTarget(target); + return t; } #endregion @@ -423,87 +473,95 @@ namespace DG.Tweening /// Also stores the transform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMove(this Transform target, Vector3 endValue, float duration, bool snapping = false) + public static TweenerCore DOMove(this Transform target, Vector3 endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.position, x => target.position = x, endValue, duration) - .SetOptions(snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.position, x => target.position = x, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// Tweens a Transform's X position to the given value. /// Also stores the transform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMoveX(this Transform target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOMoveX(this Transform target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.position, x => target.position = x, new Vector3(endValue, 0, 0), duration) - .SetOptions(AxisConstraint.X, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.position, x => target.position = x, new Vector3(endValue, 0, 0), duration); + t.SetOptions(AxisConstraint.X, snapping).SetTarget(target); + return t; } /// Tweens a Transform's Y position to the given value. /// Also stores the transform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMoveY(this Transform target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOMoveY(this Transform target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.position, x => target.position = x, new Vector3(0, endValue, 0), duration) - .SetOptions(AxisConstraint.Y, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.position, x => target.position = x, new Vector3(0, endValue, 0), duration); + t.SetOptions(AxisConstraint.Y, snapping).SetTarget(target); + return t; } /// Tweens a Transform's Z position to the given value. /// Also stores the transform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMoveZ(this Transform target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOMoveZ(this Transform target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.position, x => target.position = x, new Vector3(0, 0, endValue), duration) - .SetOptions(AxisConstraint.Z, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.position, x => target.position = x, new Vector3(0, 0, endValue), duration); + t.SetOptions(AxisConstraint.Z, snapping).SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOLocalMove(this Transform target, Vector3 endValue, float duration, bool snapping = false) + public static TweenerCore 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); + TweenerCore t = DOTween.To(() => target.localPosition, x => target.localPosition = x, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// Tweens a Transform's X localPosition to the given value. /// Also stores the transform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOLocalMoveX(this Transform target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOLocalMoveX(this Transform target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.localPosition, x => target.localPosition = x, new Vector3(endValue, 0, 0), duration) - .SetOptions(AxisConstraint.X, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.localPosition, x => target.localPosition = x, new Vector3(endValue, 0, 0), duration); + t.SetOptions(AxisConstraint.X, snapping).SetTarget(target); + return t; } /// Tweens a Transform's Y localPosition to the given value. /// Also stores the transform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOLocalMoveY(this Transform target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOLocalMoveY(this Transform target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.localPosition, x => target.localPosition = x, new Vector3(0, endValue, 0), duration) - .SetOptions(AxisConstraint.Y, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.localPosition, x => target.localPosition = x, new Vector3(0, endValue, 0), duration); + t.SetOptions(AxisConstraint.Y, snapping).SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOLocalMoveZ(this Transform target, float endValue, float duration, bool snapping = false) + public static TweenerCore 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); + TweenerCore t = DOTween.To(() => target.localPosition, x => target.localPosition = x, new Vector3(0, 0, endValue), duration); + t.SetOptions(AxisConstraint.Z, snapping).SetTarget(target); + return t; } /// Tweens a Transform's rotation to the given value. /// Also stores the transform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// Rotation mode - public static Tweener DORotate(this Transform target, Vector3 endValue, float duration, RotateMode mode = RotateMode.Fast) + public static TweenerCore DORotate(this Transform target, Vector3 endValue, float duration, RotateMode mode = RotateMode.Fast) { TweenerCore t = DOTween.To(() => target.rotation, x => target.rotation = x, endValue, duration); t.SetTarget(target); @@ -518,7 +576,7 @@ namespace DG.Tweening /// (neither for itself nor if placed inside a LoopType.Incremental Sequence) /// /// The end value to reachThe duration of the tween - public static Tweener DORotateQuaternion(this Transform target, Quaternion endValue, float duration) + public static TweenerCore DORotateQuaternion(this Transform target, Quaternion endValue, float duration) { TweenerCore t = DOTween.To(PureQuaternionPlugin.Plug(), () => target.rotation, x => target.rotation = x, endValue, duration); t.SetTarget(target); @@ -529,7 +587,7 @@ namespace DG.Tweening /// Also stores the transform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// Rotation mode - public static Tweener DOLocalRotate(this Transform target, Vector3 endValue, float duration, RotateMode mode = RotateMode.Fast) + public static TweenerCore DOLocalRotate(this Transform target, Vector3 endValue, float duration, RotateMode mode = RotateMode.Fast) { TweenerCore t = DOTween.To(() => target.localRotation, x => target.localRotation = x, endValue, duration); t.SetTarget(target); @@ -544,7 +602,7 @@ namespace DG.Tweening /// (neither for itself nor if placed inside a LoopType.Incremental Sequence) /// /// The end value to reachThe duration of the tween - public static Tweener DOLocalRotateQuaternion(this Transform target, Quaternion endValue, float duration) + public static TweenerCore DOLocalRotateQuaternion(this Transform target, Quaternion endValue, float duration) { TweenerCore t = DOTween.To(PureQuaternionPlugin.Plug(), () => target.localRotation, x => target.localRotation = x, endValue, duration); t.SetTarget(target); @@ -554,48 +612,55 @@ namespace DG.Tweening /// 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 /// The end value to reachThe duration of the tween - public static Tweener DOScale(this Transform target, Vector3 endValue, float duration) + public static TweenerCore DOScale(this Transform target, Vector3 endValue, float duration) { - return DOTween.To(() => target.localScale, x => target.localScale = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.localScale, x => target.localScale = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Transform's localScale uniformly to the given value. /// Also stores the transform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOScale(this Transform target, float endValue, float duration) + public static TweenerCore DOScale(this Transform target, float endValue, float duration) { Vector3 endValueV3 = new Vector3(endValue, endValue, endValue); - return DOTween.To(() => target.localScale, x => target.localScale = x, endValueV3, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.localScale, x => target.localScale = x, endValueV3, duration); + t.SetTarget(target); + return t; } /// Tweens a Transform's X localScale to the given value. /// Also stores the transform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOScaleX(this Transform target, float endValue, float duration) + public static TweenerCore DOScaleX(this Transform target, float endValue, float duration) { - return DOTween.To(() => target.localScale, x => target.localScale = x, new Vector3(endValue, 0, 0), duration) - .SetOptions(AxisConstraint.X) + TweenerCore t = DOTween.To(() => target.localScale, x => target.localScale = x, new Vector3(endValue, 0, 0), duration); + t.SetOptions(AxisConstraint.X) .SetTarget(target); + return t; } /// Tweens a Transform's Y localScale to the given value. /// Also stores the transform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOScaleY(this Transform target, float endValue, float duration) + public static TweenerCore DOScaleY(this Transform target, float endValue, float duration) { - return DOTween.To(() => target.localScale, x => target.localScale = x, new Vector3(0, endValue, 0), duration) - .SetOptions(AxisConstraint.Y) + TweenerCore t = DOTween.To(() => target.localScale, x => target.localScale = x, new Vector3(0, endValue, 0), duration); + t.SetOptions(AxisConstraint.Y) .SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween - public static Tweener DOScaleZ(this Transform target, float endValue, float duration) + public static TweenerCore 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) + TweenerCore t = DOTween.To(() => target.localScale, x => target.localScale = x, new Vector3(0, 0, endValue), duration); + t.SetOptions(AxisConstraint.Z) .SetTarget(target); + return t; } /// Tweens a Transform's rotation so that it will look towards the given position. @@ -950,9 +1015,11 @@ namespace DG.Tweening /// Tweens a Tween's timeScale to the given value. /// Also stores the Tween as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOTimeScale(this Tween target, float endValue, float duration) + public static TweenerCore DOTimeScale(this Tween target, float endValue, float duration) { - return DOTween.To(() => target.timeScale, x => target.timeScale = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.timeScale, x => target.timeScale = x, endValue, duration); + t.SetTarget(target); + return t; } #endregion diff --git a/_DOTween.Assembly/DOTween/TweenSettingsExtensions.cs b/_DOTween.Assembly/DOTween/TweenSettingsExtensions.cs index 637d462..f6975cb 100644 --- a/_DOTween.Assembly/DOTween/TweenSettingsExtensions.cs +++ b/_DOTween.Assembly/DOTween/TweenSettingsExtensions.cs @@ -570,6 +570,8 @@ namespace DG.Tweening #region Tweeners-only + #region FROM + /// Changes a TO tween into a FROM tween: sets the current target's position as the tween's endValue /// then immediately sends the target to the previously set endValue. public static T From(this T t) where T : Tweener @@ -593,6 +595,52 @@ namespace DG.Tweening return t; } + /// Changes a TO tween into a FROM tween: sets the tween's starting value to the given one + /// and eventually sets the tween's target to that value immediately. + /// Value to start from + /// If TRUE sets the target to from value immediately, otherwise waits for the tween to start + public static TweenerCore From(this TweenerCore t, T2 fromValue, bool setImmediately = true) + where TPlugOptions : struct, IPlugOptions + { + if (t == null || !t.active || t.creationLocked || !t.isFromAllowed) return t; + + t.isFrom = true; + t.SetFrom(fromValue, setImmediately); + return t; + } + + #region FROM Extra Overloads + + /// Changes a TO tween into a FROM tween: sets the tween's starting value to the given one + /// and eventually sets the tween's target to that value immediately. + /// Alpha value to start from (in case of Fade tweens) + /// If TRUE sets the target to from value immediately, otherwise waits for the tween to start + public static TweenerCore From(this TweenerCore t, float fromAlphaValue, bool setImmediately = true) + { + if (t == null || !t.active || t.creationLocked || !t.isFromAllowed) return t; + + t.isFrom = true; + t.SetFrom(new Color(0,0,0,fromAlphaValue), setImmediately); + return t; + } + + /// Changes a TO tween into a FROM tween: sets the tween's starting value to the given one + /// and eventually sets the tween's target to that value immediately. + /// Value to start from (in case of Vector tweens that act on a single coordinate or scale tweens) + /// If TRUE sets the target to from value immediately, otherwise waits for the tween to start + public static TweenerCore From(this TweenerCore t, float fromValue, bool setImmediately = true) + { + if (t == null || !t.active || t.creationLocked || !t.isFromAllowed) return t; + + t.isFrom = true; + t.SetFrom(new Vector3(fromValue, fromValue, fromValue), setImmediately); + return t; + } + + #endregion + + #endregion + /// Sets a delayed startup for the tween. /// Has no effect on Sequences or if the tween has already started public static T SetDelay(this T t, float delay) where T : Tween diff --git a/_DOTween.Assembly/bin/DOTween.XML b/_DOTween.Assembly/bin/DOTween.XML index 7046bfe..1345284 100644 --- a/_DOTween.Assembly/bin/DOTween.XML +++ b/_DOTween.Assembly/bin/DOTween.XML @@ -273,6 +273,9 @@ INTERNAL: do not use + + INTERNAL: do not use + INTERNAL: do not use @@ -2383,6 +2386,24 @@ then immediately sends the target to the previously set endValue. If TRUE the FROM value will be calculated as relative to the current one + + Changes a TO tween into a FROM tween: sets the tween's starting value to the given one + and eventually sets the tween's target to that value immediately. + Value to start from + If TRUE sets the target to from value immediately, otherwise waits for the tween to start + + + Changes a TO tween into a FROM tween: sets the tween's starting value to the given one + and eventually sets the tween's target to that value immediately. + Alpha value to start from (in case of Fade tweens) + If TRUE sets the target to from value immediately, otherwise waits for the tween to start + + + Changes a TO tween into a FROM tween: sets the tween's starting value to the given one + and eventually sets the tween's target to that value immediately. + Value to start from (in case of Vector tweens that act on a single coordinate or scale tweens) + If TRUE sets the target to from value immediately, otherwise waits for the tween to start + Sets a delayed startup for the tween. Has no effect on Sequences or if the tween has already started diff --git a/_DOTween.Assembly/bin/DOTween.dll b/_DOTween.Assembly/bin/DOTween.dll index d6d8103..3a0f645 100644 Binary files a/_DOTween.Assembly/bin/DOTween.dll and b/_DOTween.Assembly/bin/DOTween.dll differ diff --git a/_DOTween.Assembly/bin/DOTween.dll.mdb b/_DOTween.Assembly/bin/DOTween.dll.mdb index c80812c..f0bbf1f 100644 Binary files a/_DOTween.Assembly/bin/DOTween.dll.mdb and b/_DOTween.Assembly/bin/DOTween.dll.mdb differ diff --git a/_DOTween.Assembly/bin/Editor/DOTweenEditor.dll b/_DOTween.Assembly/bin/Editor/DOTweenEditor.dll index 19a8b05..887b1cf 100644 Binary files a/_DOTween.Assembly/bin/Editor/DOTweenEditor.dll and b/_DOTween.Assembly/bin/Editor/DOTweenEditor.dll differ diff --git a/_DOTween.Assembly/bin/Editor/DOTweenEditor.dll.mdb b/_DOTween.Assembly/bin/Editor/DOTweenEditor.dll.mdb index 3181ee1..90e94a5 100644 Binary files a/_DOTween.Assembly/bin/Editor/DOTweenEditor.dll.mdb and b/_DOTween.Assembly/bin/Editor/DOTweenEditor.dll.mdb differ diff --git a/_DOTween.Assembly/bin/Editor/DOTweenUpgradeManager.dll b/_DOTween.Assembly/bin/Editor/DOTweenUpgradeManager.dll index dd09104..56f348e 100644 Binary files a/_DOTween.Assembly/bin/Editor/DOTweenUpgradeManager.dll and b/_DOTween.Assembly/bin/Editor/DOTweenUpgradeManager.dll differ diff --git a/_DOTween.Assembly/bin/Editor/DOTweenUpgradeManager.dll.mdb b/_DOTween.Assembly/bin/Editor/DOTweenUpgradeManager.dll.mdb index f8c7588..4ec07df 100644 Binary files a/_DOTween.Assembly/bin/Editor/DOTweenUpgradeManager.dll.mdb and b/_DOTween.Assembly/bin/Editor/DOTweenUpgradeManager.dll.mdb differ diff --git a/_DOTween.Assembly/bin/Modules/DOTweenModuleAudio.cs b/_DOTween.Assembly/bin/Modules/DOTweenModuleAudio.cs index c342c02..c195b6c 100644 --- a/_DOTween.Assembly/bin/Modules/DOTweenModuleAudio.cs +++ b/_DOTween.Assembly/bin/Modules/DOTweenModuleAudio.cs @@ -3,6 +3,8 @@ #if true // MODULE_MARKER using System; +using DG.Tweening.Core; +using DG.Tweening.Plugins.Options; using UnityEngine; #if UNITY_5 || UNITY_2017_1_OR_NEWER using UnityEngine.Audio; // Required for AudioMixer @@ -20,19 +22,23 @@ namespace DG.Tweening /// Tweens an AudioSource's volume to the given value. /// Also stores the AudioSource as the tween's target so it can be used for filtered operations /// The end value to reach (0 to 1)The duration of the tween - public static Tweener DOFade(this AudioSource target, float endValue, float duration) + public static TweenerCore DOFade(this AudioSource target, float endValue, float duration) { if (endValue < 0) endValue = 0; else if (endValue > 1) endValue = 1; - return DOTween.To(() => target.volume, x => target.volume = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.volume, x => target.volume = x, endValue, duration); + t.SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween - public static Tweener DOPitch(this AudioSource target, float endValue, float duration) + public static TweenerCore DOPitch(this AudioSource target, float endValue, float duration) { - return DOTween.To(() => target.pitch, x => target.pitch = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.pitch, x => target.pitch = x, endValue, duration); + t.SetTarget(target); + return t; } #endregion @@ -45,14 +51,15 @@ namespace DG.Tweening /// Note that you need to manually expose a float in an AudioMixerGroup in order to be able to tween it from an AudioMixer. /// Name given to the exposed float to set /// The end value to reachThe duration of the tween - public static Tweener DOSetFloat(this AudioMixer target, string floatName, float endValue, float duration) + public static TweenerCore DOSetFloat(this AudioMixer target, string floatName, float endValue, float duration) { - return DOTween.To(()=> { + TweenerCore t = DOTween.To(()=> { float currVal; target.GetFloat(floatName, out currVal); return currVal; - }, x=> target.SetFloat(floatName, x), endValue, duration) - .SetTarget(target); + }, x=> target.SetFloat(floatName, x), endValue, duration); + t.SetTarget(target); + return t; } #region Operation Shortcuts diff --git a/_DOTween.Assembly/bin/Modules/DOTweenModulePhysics.cs b/_DOTween.Assembly/bin/Modules/DOTweenModulePhysics.cs index 2a85cc6..a1a1cb9 100644 --- a/_DOTween.Assembly/bin/Modules/DOTweenModulePhysics.cs +++ b/_DOTween.Assembly/bin/Modules/DOTweenModulePhysics.cs @@ -23,47 +23,51 @@ namespace DG.Tweening /// Also stores the rigidbody as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMove(this Rigidbody target, Vector3 endValue, float duration, bool snapping = false) + public static TweenerCore DOMove(this Rigidbody target, Vector3 endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.position, target.MovePosition, endValue, duration) - .SetOptions(snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.position, target.MovePosition, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// Tweens a Rigidbody's X position to the given value. /// Also stores the rigidbody as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMoveX(this Rigidbody target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOMoveX(this Rigidbody target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.position, target.MovePosition, new Vector3(endValue, 0, 0), duration) - .SetOptions(AxisConstraint.X, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.position, target.MovePosition, new Vector3(endValue, 0, 0), duration); + t.SetOptions(AxisConstraint.X, snapping).SetTarget(target); + return t; } /// Tweens a Rigidbody's Y position to the given value. /// Also stores the rigidbody as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMoveY(this Rigidbody target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOMoveY(this Rigidbody target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.position, target.MovePosition, new Vector3(0, endValue, 0), duration) - .SetOptions(AxisConstraint.Y, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.position, target.MovePosition, new Vector3(0, endValue, 0), duration); + t.SetOptions(AxisConstraint.Y, snapping).SetTarget(target); + return t; } /// Tweens a Rigidbody's Z position to the given value. /// Also stores the rigidbody as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMoveZ(this Rigidbody target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOMoveZ(this Rigidbody target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.position, target.MovePosition, new Vector3(0, 0, endValue), duration) - .SetOptions(AxisConstraint.Z, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.position, target.MovePosition, new Vector3(0, 0, endValue), duration); + t.SetOptions(AxisConstraint.Z, snapping).SetTarget(target); + return t; } /// Tweens a Rigidbody's rotation to the given value. /// Also stores the rigidbody as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// Rotation mode - public static Tweener DORotate(this Rigidbody target, Vector3 endValue, float duration, RotateMode mode = RotateMode.Fast) + public static TweenerCore DORotate(this Rigidbody target, Vector3 endValue, float duration, RotateMode mode = RotateMode.Fast) { TweenerCore t = DOTween.To(() => target.rotation, target.MoveRotation, endValue, duration); t.SetTarget(target); @@ -76,7 +80,7 @@ namespace DG.Tweening /// The position to look atThe duration of the tween /// Eventual axis constraint for the rotation /// The vector that defines in which direction up is (default: Vector3.up) - public static Tweener DOLookAt(this Rigidbody target, Vector3 towards, float duration, AxisConstraint axisConstraint = AxisConstraint.None, Vector3? up = null) + public static TweenerCore DOLookAt(this Rigidbody target, Vector3 towards, float duration, AxisConstraint axisConstraint = AxisConstraint.None, Vector3? up = null) { TweenerCore t = DOTween.To(() => target.rotation, target.MoveRotation, towards, duration) .SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetLookAt); diff --git a/_DOTween.Assembly/bin/Modules/DOTweenModulePhysics2D.cs b/_DOTween.Assembly/bin/Modules/DOTweenModulePhysics2D.cs index f4e2aa2..f40a7d0 100644 --- a/_DOTween.Assembly/bin/Modules/DOTweenModulePhysics2D.cs +++ b/_DOTween.Assembly/bin/Modules/DOTweenModulePhysics2D.cs @@ -3,6 +3,8 @@ #if true && (UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER) // MODULE_MARKER using System; +using DG.Tweening.Core; +using DG.Tweening.Plugins.Options; using UnityEngine; #pragma warning disable 1591 @@ -18,39 +20,43 @@ namespace DG.Tweening /// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMove(this Rigidbody2D target, Vector2 endValue, float duration, bool snapping = false) + public static TweenerCore DOMove(this Rigidbody2D target, Vector2 endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.position, target.MovePosition, endValue, duration) - .SetOptions(snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.position, target.MovePosition, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMoveX(this Rigidbody2D target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOMoveX(this Rigidbody2D target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.position, target.MovePosition, new Vector2(endValue, 0), duration) - .SetOptions(AxisConstraint.X, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.position, target.MovePosition, new Vector2(endValue, 0), duration); + t.SetOptions(AxisConstraint.X, snapping).SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMoveY(this Rigidbody2D target, float endValue, float duration, bool snapping = false) + public static TweenerCore 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); + TweenerCore t = DOTween.To(() => target.position, target.MovePosition, new Vector2(0, endValue), duration); + t.SetOptions(AxisConstraint.Y, snapping).SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween - public static Tweener DORotate(this Rigidbody2D target, float endValue, float duration) + public static TweenerCore DORotate(this Rigidbody2D target, float endValue, float duration) { - return DOTween.To(() => target.rotation, target.MoveRotation, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.To(() => target.rotation, target.MoveRotation, endValue, duration); + t.SetTarget(target); + return t; } #region Special diff --git a/_DOTween.Assembly/bin/Modules/DOTweenModuleSprite.cs b/_DOTween.Assembly/bin/Modules/DOTweenModuleSprite.cs index 12e07aa..9450ca5 100644 --- a/_DOTween.Assembly/bin/Modules/DOTweenModuleSprite.cs +++ b/_DOTween.Assembly/bin/Modules/DOTweenModuleSprite.cs @@ -5,6 +5,7 @@ using System; using UnityEngine; using DG.Tweening.Core; +using DG.Tweening.Plugins.Options; #pragma warning disable 1591 namespace DG.Tweening @@ -18,18 +19,21 @@ namespace DG.Tweening /// Tweens a SpriteRenderer's color to the given value. /// Also stores the spriteRenderer as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOColor(this SpriteRenderer target, Color endValue, float duration) + public static TweenerCore DOColor(this SpriteRenderer target, Color endValue, float duration) { - return DOTween.To(() => target.color, x => target.color = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.color, x => target.color = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Material's alpha color to the given value. /// Also stores the spriteRenderer as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOFade(this SpriteRenderer target, float endValue, float duration) + public static TweenerCore DOFade(this SpriteRenderer target, float endValue, float duration) { - return DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a SpriteRenderer's color using the given gradient diff --git a/_DOTween.Assembly/bin/Modules/DOTweenModuleUI.cs b/_DOTween.Assembly/bin/Modules/DOTweenModuleUI.cs index df2b42c..072c02c 100644 --- a/_DOTween.Assembly/bin/Modules/DOTweenModuleUI.cs +++ b/_DOTween.Assembly/bin/Modules/DOTweenModuleUI.cs @@ -7,6 +7,7 @@ using UnityEngine; using UnityEngine.UI; using DG.Tweening.Core; using DG.Tweening.Core.Enums; +using DG.Tweening.Plugins.Options; #pragma warning disable 1591 namespace DG.Tweening @@ -20,10 +21,11 @@ namespace DG.Tweening /// 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 /// The end value to reachThe duration of the tween - public static Tweener DOFade(this CanvasGroup target, float endValue, float duration) + public static TweenerCore DOFade(this CanvasGroup target, float endValue, float duration) { - return DOTween.To(() => target.alpha, x => target.alpha = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.To(() => target.alpha, x => target.alpha = x, endValue, duration); + t.SetTarget(target); + return t; } #endregion @@ -33,18 +35,21 @@ namespace DG.Tweening /// Tweens an Graphic's color to the given value. /// Also stores the image as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOColor(this Graphic target, Color endValue, float duration) + public static TweenerCore DOColor(this Graphic target, Color endValue, float duration) { - return DOTween.To(() => target.color, x => target.color = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.color, x => target.color = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens an Graphic's alpha color to the given value. /// Also stores the image as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOFade(this Graphic target, float endValue, float duration) + public static TweenerCore DOFade(this Graphic target, float endValue, float duration) { - return DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration); + t.SetTarget(target); + return t; } #endregion @@ -54,29 +59,33 @@ namespace DG.Tweening /// 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 /// The end value to reachThe duration of the tween - public static Tweener DOColor(this Image target, Color endValue, float duration) + public static TweenerCore DOColor(this Image target, Color endValue, float duration) { - return DOTween.To(() => target.color, x => target.color = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.color, x => target.color = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens an Image's alpha color to the given value. /// Also stores the image as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOFade(this Image target, float endValue, float duration) + public static TweenerCore DOFade(this Image target, float endValue, float duration) { - return DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens an Image's fillAmount to the given value. /// Also stores the image as the tween's target so it can be used for filtered operations /// The end value to reach (0 to 1)The duration of the tween - public static Tweener DOFillAmount(this Image target, float endValue, float duration) + public static TweenerCore DOFillAmount(this Image target, float endValue, float duration) { if (endValue > 1) endValue = 1; else if (endValue < 0) endValue = 0; - return DOTween.To(() => target.fillAmount, x => target.fillAmount = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.To(() => target.fillAmount, x => target.fillAmount = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens an Image's colors using the given gradient @@ -110,39 +119,42 @@ namespace DG.Tweening /// Also stores the LayoutElement as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOFlexibleSize(this LayoutElement target, Vector2 endValue, float duration, bool snapping = false) + public static TweenerCore DOFlexibleSize(this LayoutElement target, Vector2 endValue, float duration, bool snapping = false) { - return DOTween.To(() => new Vector2(target.flexibleWidth, target.flexibleHeight), x => { + TweenerCore t = DOTween.To(() => new Vector2(target.flexibleWidth, target.flexibleHeight), x => { target.flexibleWidth = x.x; target.flexibleHeight = x.y; - }, endValue, duration) - .SetOptions(snapping).SetTarget(target); + }, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// Tweens an LayoutElement's minWidth/Height to the given value. /// Also stores the LayoutElement as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOMinSize(this LayoutElement target, Vector2 endValue, float duration, bool snapping = false) + public static TweenerCore DOMinSize(this LayoutElement target, Vector2 endValue, float duration, bool snapping = false) { - return DOTween.To(() => new Vector2(target.minWidth, target.minHeight), x => { + TweenerCore t = DOTween.To(() => new Vector2(target.minWidth, target.minHeight), x => { target.minWidth = x.x; target.minHeight = x.y; - }, endValue, duration) - .SetOptions(snapping).SetTarget(target); + }, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// Tweens an LayoutElement's preferredWidth/Height to the given value. /// Also stores the LayoutElement as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOPreferredSize(this LayoutElement target, Vector2 endValue, float duration, bool snapping = false) + public static TweenerCore DOPreferredSize(this LayoutElement target, Vector2 endValue, float duration, bool snapping = false) { - return DOTween.To(() => new Vector2(target.preferredWidth, target.preferredHeight), x => { + TweenerCore t = DOTween.To(() => new Vector2(target.preferredWidth, target.preferredHeight), x => { target.preferredWidth = x.x; target.preferredHeight = x.y; - }, endValue, duration) - .SetOptions(snapping).SetTarget(target); + }, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } #endregion @@ -152,27 +164,31 @@ namespace DG.Tweening /// Tweens a Outline's effectColor to the given value. /// Also stores the Outline as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOColor(this Outline target, Color endValue, float duration) + public static TweenerCore DOColor(this Outline target, Color endValue, float duration) { - return DOTween.To(() => target.effectColor, x => target.effectColor = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.effectColor, x => target.effectColor = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Outline's effectColor alpha to the given value. /// Also stores the Outline as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOFade(this Outline target, float endValue, float duration) + public static TweenerCore DOFade(this Outline target, float endValue, float duration) { - return DOTween.ToAlpha(() => target.effectColor, x => target.effectColor = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.ToAlpha(() => target.effectColor, x => target.effectColor = x, endValue, duration); + t.SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween - public static Tweener DOScale(this Outline target, Vector2 endValue, float duration) + public static TweenerCore DOScale(this Outline target, Vector2 endValue, float duration) { - return DOTween.To(() => target.effectDistance, x => target.effectDistance = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.To(() => target.effectDistance, x => target.effectDistance = x, endValue, duration); + t.SetTarget(target); + return t; } #endregion @@ -183,120 +199,133 @@ namespace DG.Tweening /// Also stores the RectTransform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOAnchorPos(this RectTransform target, Vector2 endValue, float duration, bool snapping = false) + public static TweenerCore DOAnchorPos(this RectTransform target, Vector2 endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, endValue, duration) - .SetOptions(snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// Tweens a RectTransform's anchoredPosition X to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOAnchorPosX(this RectTransform target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOAnchorPosX(this RectTransform target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(endValue, 0), duration) - .SetOptions(AxisConstraint.X, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(endValue, 0), duration); + t.SetOptions(AxisConstraint.X, snapping).SetTarget(target); + return t; } /// Tweens a RectTransform's anchoredPosition Y to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOAnchorPosY(this RectTransform target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOAnchorPosY(this RectTransform target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(0, endValue), duration) - .SetOptions(AxisConstraint.Y, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(0, endValue), duration); + t.SetOptions(AxisConstraint.Y, snapping).SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOAnchorPos3D(this RectTransform target, Vector3 endValue, float duration, bool snapping = false) + public static TweenerCore 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); + TweenerCore t = DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// Tweens a RectTransform's anchoredPosition3D X to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOAnchorPos3DX(this RectTransform target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOAnchorPos3DX(this RectTransform target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, new Vector3(endValue, 0, 0), duration) - .SetOptions(AxisConstraint.X, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, new Vector3(endValue, 0, 0), duration); + t.SetOptions(AxisConstraint.X, snapping).SetTarget(target); + return t; } /// Tweens a RectTransform's anchoredPosition3D Y to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOAnchorPos3DY(this RectTransform target, float endValue, float duration, bool snapping = false) + public static TweenerCore DOAnchorPos3DY(this RectTransform target, float endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, new Vector3(0, endValue, 0), duration) - .SetOptions(AxisConstraint.Y, snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, new Vector3(0, endValue, 0), duration); + t.SetOptions(AxisConstraint.Y, snapping).SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOAnchorPos3DZ(this RectTransform target, float endValue, float duration, bool snapping = false) + public static TweenerCore 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); + TweenerCore t = DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, new Vector3(0, 0, endValue), duration); + t.SetOptions(AxisConstraint.Z, snapping).SetTarget(target); + return t; } /// Tweens a RectTransform's anchorMax to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOAnchorMax(this RectTransform target, Vector2 endValue, float duration, bool snapping = false) + public static TweenerCore DOAnchorMax(this RectTransform target, Vector2 endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.anchorMax, x => target.anchorMax = x, endValue, duration) - .SetOptions(snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.anchorMax, x => target.anchorMax = x, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// Tweens a RectTransform's anchorMin to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOAnchorMin(this RectTransform target, Vector2 endValue, float duration, bool snapping = false) + public static TweenerCore DOAnchorMin(this RectTransform target, Vector2 endValue, float duration, bool snapping = false) { - return DOTween.To(() => target.anchorMin, x => target.anchorMin = x, endValue, duration) - .SetOptions(snapping).SetTarget(target); + TweenerCore t = DOTween.To(() => target.anchorMin, x => target.anchorMin = x, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween - public static Tweener DOPivot(this RectTransform target, Vector2 endValue, float duration) + public static TweenerCore DOPivot(this RectTransform target, Vector2 endValue, float duration) { - return DOTween.To(() => target.pivot, x => target.pivot = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.To(() => target.pivot, x => target.pivot = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a RectTransform's pivot X to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOPivotX(this RectTransform target, float endValue, float duration) + public static TweenerCore DOPivotX(this RectTransform target, float endValue, float duration) { - return DOTween.To(() => target.pivot, x => target.pivot = x, new Vector2(endValue, 0), duration) - .SetOptions(AxisConstraint.X).SetTarget(target); + TweenerCore t = DOTween.To(() => target.pivot, x => target.pivot = x, new Vector2(endValue, 0), duration); + t.SetOptions(AxisConstraint.X).SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween - public static Tweener DOPivotY(this RectTransform target, float endValue, float duration) + public static TweenerCore 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); + TweenerCore t = DOTween.To(() => target.pivot, x => target.pivot = x, new Vector2(0, endValue), duration); + t.SetOptions(AxisConstraint.Y).SetTarget(target); + return t; } /// 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 /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOSizeDelta(this RectTransform target, Vector2 endValue, float duration, bool snapping = false) + public static TweenerCore 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); + TweenerCore t = DOTween.To(() => target.sizeDelta, x => target.sizeDelta = x, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } /// Punches a RectTransform's anchoredPosition towards the given direction and then back to the starting one @@ -430,10 +459,11 @@ namespace DG.Tweening /// Also stores the Slider as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween /// If TRUE the tween will smoothly snap all values to integers - public static Tweener DOValue(this Slider target, float endValue, float duration, bool snapping = false) + public static TweenerCore 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); + TweenerCore t = DOTween.To(() => target.value, x => target.value = x, endValue, duration); + t.SetOptions(snapping).SetTarget(target); + return t; } #endregion @@ -443,18 +473,21 @@ namespace DG.Tweening /// Tweens a Text's color to the given value. /// Also stores the Text as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOColor(this Text target, Color endValue, float duration) + public static TweenerCore DOColor(this Text target, Color endValue, float duration) { - return DOTween.To(() => target.color, x => target.color = x, endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.color, x => target.color = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Text's alpha color to the given value. /// Also stores the Text as the tween's target so it can be used for filtered operations /// The end value to reachThe duration of the tween - public static Tweener DOFade(this Text target, float endValue, float duration) + public static TweenerCore DOFade(this Text target, float endValue, float duration) { - return DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration) - .SetTarget(target); + TweenerCore t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Text's text to the given value. @@ -466,11 +499,12 @@ namespace DG.Tweening /// 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 - public static Tweener DOText(this Text target, string endValue, float duration, bool richTextEnabled = true, ScrambleMode scrambleMode = ScrambleMode.None, string scrambleChars = null) + public static TweenerCore 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) + TweenerCore t = DOTween.To(() => target.text, x => target.text = x, endValue, duration); + t.SetOptions(richTextEnabled, scrambleMode, scrambleChars) .SetTarget(target); + return t; } #endregion diff --git a/_DOTween.Assembly/bin/Modules/DOTweenModuleUnityVersion.cs b/_DOTween.Assembly/bin/Modules/DOTweenModuleUnityVersion.cs index caede5e..176ecae 100644 --- a/_DOTween.Assembly/bin/Modules/DOTweenModuleUnityVersion.cs +++ b/_DOTween.Assembly/bin/Modules/DOTweenModuleUnityVersion.cs @@ -4,6 +4,7 @@ using System; using UnityEngine; using DG.Tweening.Core; +using DG.Tweening.Plugins.Options; #pragma warning disable 1591 namespace DG.Tweening @@ -178,13 +179,15 @@ namespace DG.Tweening /// The end value to reach /// The ID of the material property to tween (also called nameID in Unity's manual) /// The duration of the tween - public static Tweener DOOffset(this Material target, Vector2 endValue, int propertyID, float duration) + public static TweenerCore DOOffset(this Material target, Vector2 endValue, int propertyID, float duration) { if (!target.HasProperty(propertyID)) { if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID); return null; } - return DOTween.To(() => target.GetTextureOffset(propertyID), x => target.SetTextureOffset(propertyID, x), endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.GetTextureOffset(propertyID), x => target.SetTextureOffset(propertyID, x), endValue, duration); + t.SetTarget(target); + return t; } /// Tweens a Material's named texture scale property with the given ID to the given value. @@ -192,13 +195,15 @@ namespace DG.Tweening /// The end value to reach /// The ID of the material property to tween (also called nameID in Unity's manual) /// The duration of the tween - public static Tweener DOTiling(this Material target, Vector2 endValue, int propertyID, float duration) + public static TweenerCore DOTiling(this Material target, Vector2 endValue, int propertyID, float duration) { if (!target.HasProperty(propertyID)) { if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID); return null; } - return DOTween.To(() => target.GetTextureScale(propertyID), x => target.SetTextureScale(propertyID, x), endValue, duration).SetTarget(target); + TweenerCore t = DOTween.To(() => target.GetTextureScale(propertyID), x => target.SetTextureScale(propertyID, x), endValue, duration); + t.SetTarget(target); + return t; } #endregion