mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2025-12-20 17:26:03 +08:00
Added Material/SpriteRenderer/Image DOGradientColor + Fixed DOJump not working correctly with Rigidbody2D
This commit is contained in:
parent
bc6cace7e8
commit
e2b5ae40a6
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -10,6 +10,20 @@
|
||||
These, as all DOTween43 methods, require Unity 4.3 or later.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOGradientColor(UnityEngine.Material,UnityEngine.Gradient,System.Single)">
|
||||
<summary>Tweens a Material's color using the given gradient
|
||||
(NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="gradient">The gradient to use</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOGradientColor(UnityEngine.Material,UnityEngine.Gradient,System.String,System.Single)">
|
||||
<summary>Tweens a Material's named color property using the given gradient
|
||||
(NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="gradient">The gradient to use</param>
|
||||
<param name="property">The name of the material property to tween (like _Tint or _SpecColor)</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOColor(UnityEngine.SpriteRenderer,UnityEngine.Color,System.Single)">
|
||||
<summary>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</summary>
|
||||
@ -20,6 +34,12 @@
|
||||
Also stores the spriteRenderer as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOGradientColor(UnityEngine.SpriteRenderer,UnityEngine.Gradient,System.Single)">
|
||||
<summary>Tweens a SpriteRenderer's colors using the given gradient
|
||||
(NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="gradient">The gradient to use</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOMove(UnityEngine.Rigidbody2D,UnityEngine.Vector2,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Rigidbody2D's position to the given value.
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
@ -46,7 +66,8 @@
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOJump(UnityEngine.Rigidbody2D,UnityEngine.Vector2,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Rigidbody2D's position to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations.
|
||||
<para>IMPORTANT: a rigidbody2D can't be animated in a jump arc using MovePosition, so the tween will directly set the position</para></summary>
|
||||
<param name="endValue">The end value to reach</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -51,6 +51,12 @@
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The end value to reach (0 to 1)</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions46.DOGradientColor(UnityEngine.UI.Image,UnityEngine.Gradient,System.Single)">
|
||||
<summary>Tweens an Image's colors using the given gradient
|
||||
(NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="gradient">The gradient to use</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions46.DOFlexibleSize(UnityEngine.UI.LayoutElement,UnityEngine.Vector2,System.Single,System.Boolean)">
|
||||
<summary>Tweens an LayoutElement's flexibleWidth/Height to the given value.
|
||||
Also stores the LayoutElement as the tween's target so it can be used for filtered operations</summary>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -10,6 +10,20 @@
|
||||
These, as all DOTween43 methods, require Unity 4.3 or later.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOGradientColor(UnityEngine.Material,UnityEngine.Gradient,System.Single)">
|
||||
<summary>Tweens a Material's color using the given gradient
|
||||
(NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="gradient">The gradient to use</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOGradientColor(UnityEngine.Material,UnityEngine.Gradient,System.String,System.Single)">
|
||||
<summary>Tweens a Material's named color property using the given gradient
|
||||
(NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="gradient">The gradient to use</param>
|
||||
<param name="property">The name of the material property to tween (like _Tint or _SpecColor)</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOColor(UnityEngine.SpriteRenderer,UnityEngine.Color,System.Single)">
|
||||
<summary>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</summary>
|
||||
@ -20,6 +34,12 @@
|
||||
Also stores the spriteRenderer as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOGradientColor(UnityEngine.SpriteRenderer,UnityEngine.Gradient,System.Single)">
|
||||
<summary>Tweens a SpriteRenderer's colors using the given gradient
|
||||
(NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="gradient">The gradient to use</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOMove(UnityEngine.Rigidbody2D,UnityEngine.Vector2,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Rigidbody2D's position to the given value.
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
@ -46,7 +66,8 @@
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOJump(UnityEngine.Rigidbody2D,UnityEngine.Vector2,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Rigidbody2D's position to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations.
|
||||
<para>IMPORTANT: a rigidbody2D can't be animated in a jump arc using MovePosition, so the tween will directly set the position</para></summary>
|
||||
<param name="endValue">The end value to reach</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -51,6 +51,12 @@
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The end value to reach (0 to 1)</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions46.DOGradientColor(UnityEngine.UI.Image,UnityEngine.Gradient,System.Single)">
|
||||
<summary>Tweens an Image's colors using the given gradient
|
||||
(NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="gradient">The gradient to use</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions46.DOFlexibleSize(UnityEngine.UI.LayoutElement,UnityEngine.Vector2,System.Single,System.Boolean)">
|
||||
<summary>Tweens an LayoutElement's flexibleWidth/Height to the given value.
|
||||
Also stores the LayoutElement as the tween's target so it can be used for filtered operations</summary>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -10,6 +10,20 @@
|
||||
These, as all DOTween43 methods, require Unity 4.3 or later.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOGradientColor(UnityEngine.Material,UnityEngine.Gradient,System.Single)">
|
||||
<summary>Tweens a Material's color using the given gradient
|
||||
(NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="gradient">The gradient to use</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOGradientColor(UnityEngine.Material,UnityEngine.Gradient,System.String,System.Single)">
|
||||
<summary>Tweens a Material's named color property using the given gradient
|
||||
(NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="gradient">The gradient to use</param>
|
||||
<param name="property">The name of the material property to tween (like _Tint or _SpecColor)</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOColor(UnityEngine.SpriteRenderer,UnityEngine.Color,System.Single)">
|
||||
<summary>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</summary>
|
||||
@ -20,6 +34,12 @@
|
||||
Also stores the spriteRenderer as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOGradientColor(UnityEngine.SpriteRenderer,UnityEngine.Gradient,System.Single)">
|
||||
<summary>Tweens a SpriteRenderer's colors using the given gradient
|
||||
(NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="gradient">The gradient to use</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOMove(UnityEngine.Rigidbody2D,UnityEngine.Vector2,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Rigidbody2D's position to the given value.
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
@ -46,7 +66,8 @@
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOJump(UnityEngine.Rigidbody2D,UnityEngine.Vector2,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Rigidbody2D's position to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations.
|
||||
<para>IMPORTANT: a rigidbody2D can't be animated in a jump arc using MovePosition, so the tween will directly set the position</para></summary>
|
||||
<param name="endValue">The end value to reach</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -51,6 +51,12 @@
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The end value to reach (0 to 1)</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions46.DOGradientColor(UnityEngine.UI.Image,UnityEngine.Gradient,System.Single)">
|
||||
<summary>Tweens an Image's colors using the given gradient
|
||||
(NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="gradient">The gradient to use</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions46.DOFlexibleSize(UnityEngine.UI.LayoutElement,UnityEngine.Vector2,System.Single,System.Boolean)">
|
||||
<summary>Tweens an LayoutElement's flexibleWidth/Height to the given value.
|
||||
Also stores the LayoutElement as the tween's target so it can be used for filtered operations</summary>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
UnityTests.Unity5/Assets/_DOTween Pro Examples/_LightFade.unity
Normal file
BIN
UnityTests.Unity5/Assets/_DOTween Pro Examples/_LightFade.unity
Normal file
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff9f3d81e30130643bf3e3b67c0674b5
|
||||
timeCreated: 1442748793
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
18
UnityTests.Unity5/Assets/_Tests/DOJumpRigidbody2D.cs
Normal file
18
UnityTests.Unity5/Assets/_Tests/DOJumpRigidbody2D.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using DG.Tweening;
|
||||
|
||||
public class DOJumpRigidbody2D : MonoBehaviour
|
||||
{
|
||||
public Rigidbody r3D;
|
||||
public Rigidbody2D r2D;
|
||||
|
||||
IEnumerator Start()
|
||||
{
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
r3D.DOJump(new Vector3(5f, 0, 0), 3f, 2, 2f, false);
|
||||
r2D.DOJump(new Vector2(5f, 0), 3f, 2, 2f, false);
|
||||
// r2D.transform.DOJump(new Vector2(5f, 0), 3f, 2, 2f, false);
|
||||
}
|
||||
}
|
||||
12
UnityTests.Unity5/Assets/_Tests/DOJumpRigidbody2D.cs.meta
Normal file
12
UnityTests.Unity5/Assets/_Tests/DOJumpRigidbody2D.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b8392de904468245aed99718958ff20
|
||||
timeCreated: 1443177456
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
UnityTests.Unity5/Assets/_Tests/DOJumpRigidbody2D.unity
Normal file
BIN
UnityTests.Unity5/Assets/_Tests/DOJumpRigidbody2D.unity
Normal file
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0861582ce1d46a409d07724df4cd4c4
|
||||
timeCreated: 1443177448
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -32,7 +32,7 @@ namespace DG.Tweening
|
||||
public class DOTween
|
||||
{
|
||||
/// <summary>DOTween's version</summary>
|
||||
public static readonly string Version = "1.0.830";
|
||||
public static readonly string Version = "1.0.850";
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// Options ////////////////////////////////////
|
||||
|
||||
@ -451,7 +451,7 @@ namespace DG.Tweening
|
||||
.SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear)
|
||||
.OnUpdate(() => {
|
||||
if (!offsetYSet) {
|
||||
offsetYSet = false;
|
||||
offsetYSet = true;
|
||||
offsetY = s.isRelative ? endValue.y : endValue.y - startPosY;
|
||||
}
|
||||
Vector3 pos = target.position;
|
||||
@ -810,7 +810,7 @@ namespace DG.Tweening
|
||||
.SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear)
|
||||
.OnUpdate(() => {
|
||||
if (!offsetYSet) {
|
||||
offsetYSet = false;
|
||||
offsetYSet = true;
|
||||
offsetY = s.isRelative ? endValue.y : endValue.y - startPosY;
|
||||
}
|
||||
Vector3 pos = target.position;
|
||||
|
||||
@ -15,6 +15,57 @@ namespace DG.Tweening
|
||||
/// </summary>
|
||||
public static class ShortcutExtensions43
|
||||
{
|
||||
#region Material
|
||||
|
||||
/// <summary>Tweens a Material's color using the given gradient
|
||||
/// (NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
/// Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="gradient">The gradient to use</param><param name="duration">The duration of the tween</param>
|
||||
public static Sequence DOGradientColor(this Material target, Gradient gradient, float duration)
|
||||
{
|
||||
Sequence s = DOTween.Sequence();
|
||||
GradientColorKey[] colors = gradient.colorKeys;
|
||||
int len = colors.Length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
GradientColorKey c = colors[i];
|
||||
if (i == 0 && c.time <= 0) {
|
||||
target.color = c.color;
|
||||
continue;
|
||||
}
|
||||
float colorDuration = i == len - 1
|
||||
? duration - s.Duration(false) // Verifies that total duration is correct
|
||||
: duration * (i == 0 ? c.time : c.time - colors[i - 1].time);
|
||||
s.Append(target.DOColor(c.color, colorDuration).SetEase(Ease.Linear));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
/// <summary>Tweens a Material's named color property using the given gradient
|
||||
/// (NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
/// Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="gradient">The gradient to use</param>
|
||||
/// <param name="property">The name of the material property to tween (like _Tint or _SpecColor)</param>
|
||||
/// <param name="duration">The duration of the tween</param>
|
||||
public static Sequence DOGradientColor(this Material target, Gradient gradient, string property, float duration)
|
||||
{
|
||||
Sequence s = DOTween.Sequence();
|
||||
GradientColorKey[] colors = gradient.colorKeys;
|
||||
int len = colors.Length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
GradientColorKey c = colors[i];
|
||||
if (i == 0 && c.time <= 0) {
|
||||
target.color = c.color;
|
||||
continue;
|
||||
}
|
||||
float colorDuration = i == len - 1
|
||||
? duration - s.Duration(false) // Verifies that total duration is correct
|
||||
: duration * (i == 0 ? c.time : c.time - colors[i - 1].time);
|
||||
s.Append(target.DOColor(c.color, property, colorDuration).SetEase(Ease.Linear));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SpriteRenderer
|
||||
|
||||
/// <summary>Tweens a SpriteRenderer's color to the given value.
|
||||
@ -34,6 +85,29 @@ namespace DG.Tweening
|
||||
.SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens a SpriteRenderer's colors using the given gradient
|
||||
/// (NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
/// Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="gradient">The gradient to use</param><param name="duration">The duration of the tween</param>
|
||||
public static Sequence DOGradientColor(this SpriteRenderer target, Gradient gradient, float duration)
|
||||
{
|
||||
Sequence s = DOTween.Sequence();
|
||||
GradientColorKey[] colors = gradient.colorKeys;
|
||||
int len = colors.Length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
GradientColorKey c = colors[i];
|
||||
if (i == 0 && c.time <= 0) {
|
||||
target.color = c.color;
|
||||
continue;
|
||||
}
|
||||
float colorDuration = i == len - 1
|
||||
? duration - s.Duration(false) // Verifies that total duration is correct
|
||||
: duration * (i == 0 ? c.time : c.time - colors[i - 1].time);
|
||||
s.Append(target.DOColor(c.color, colorDuration).SetEase(Ease.Linear));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Rigidbody2D Shortcuts
|
||||
@ -93,7 +167,8 @@ namespace DG.Tweening
|
||||
|
||||
/// <summary>Tweens a Rigidbody2D's position to the given value, while also applying a jump effect along the Y axis.
|
||||
/// Returns a Sequence instead of a Tweener.
|
||||
/// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
/// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations.
|
||||
/// <para>IMPORTANT: a rigidbody2D can't be animated in a jump arc using MovePosition, so the tween will directly set the position</para></summary>
|
||||
/// <param name="endValue">The end value to reach</param>
|
||||
/// <param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
/// <param name="numJumps">Total number of jumps</param>
|
||||
@ -107,24 +182,24 @@ namespace DG.Tweening
|
||||
bool offsetYSet = false;
|
||||
Sequence s = DOTween.Sequence();
|
||||
#if COMPATIBLE
|
||||
s.Append(DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector3(endValue.x, 0, 0), duration)
|
||||
s.Append(DOTween.To(() => target.position, x => target.position = x.value, new Vector3(endValue.x, 0, 0), duration)
|
||||
#else
|
||||
s.Append(DOTween.To(() => target.position, target.MovePosition, new Vector2(endValue.x, 0), duration)
|
||||
s.Append(DOTween.To(() => target.position, x => target.position = x, new Vector2(endValue.x, 0), duration)
|
||||
#endif
|
||||
.SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear)
|
||||
.OnUpdate(() => {
|
||||
if (!offsetYSet) {
|
||||
offsetYSet = false;
|
||||
offsetYSet = true;
|
||||
offsetY = s.isRelative ? endValue.y : endValue.y - startPosY;
|
||||
}
|
||||
Vector2 pos = target.position;
|
||||
pos.y += DOVirtual.EasedValue(0, offsetY, s.ElapsedDirectionalPercentage(), Ease.OutQuad);
|
||||
target.MovePosition(pos);
|
||||
target.position = pos;
|
||||
})
|
||||
#if COMPATIBLE
|
||||
).Join(DOTween.To(() => target.position, x => target.MovePosition(x.value), new Vector3(0, jumpPower, 0), duration / (numJumps * 2))
|
||||
).Join(DOTween.To(() => target.position, x => target.position = x.value, new Vector3(0, jumpPower, 0), duration / (numJumps * 2))
|
||||
#else
|
||||
).Join(DOTween.To(() => target.position, target.MovePosition, new Vector2(0, jumpPower), duration / (numJumps * 2))
|
||||
).Join(DOTween.To(() => target.position, x=> target.position = x, new Vector2(0, jumpPower), duration / (numJumps * 2))
|
||||
#endif
|
||||
.SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad)
|
||||
.SetLoops(numJumps * 2, LoopType.Yoyo).SetRelative()
|
||||
|
||||
@ -83,6 +83,29 @@ namespace DG.Tweening
|
||||
.SetTarget(target);
|
||||
}
|
||||
|
||||
/// <summary>Tweens an Image's colors using the given gradient
|
||||
/// (NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
/// Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
/// <param name="gradient">The gradient to use</param><param name="duration">The duration of the tween</param>
|
||||
public static Sequence DOGradientColor(this Image target, Gradient gradient, float duration)
|
||||
{
|
||||
Sequence s = DOTween.Sequence();
|
||||
GradientColorKey[] colors = gradient.colorKeys;
|
||||
int len = colors.Length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
GradientColorKey c = colors[i];
|
||||
if (i == 0 && c.time <= 0) {
|
||||
target.color = c.color;
|
||||
continue;
|
||||
}
|
||||
float colorDuration = i == len - 1
|
||||
? duration - s.Duration(false) // Verifies that total duration is correct
|
||||
: duration * (i == 0 ? c.time : c.time - colors[i - 1].time);
|
||||
s.Append(target.DOColor(c.color, colorDuration).SetEase(Ease.Linear));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LayoutElement
|
||||
@ -273,7 +296,7 @@ namespace DG.Tweening
|
||||
).SetTarget(target).SetEase(DOTween.defaultEaseType);
|
||||
s.OnUpdate(() => {
|
||||
if (!offsetYSet) {
|
||||
offsetYSet = false;
|
||||
offsetYSet = true;
|
||||
offsetY = s.isRelative ? endValue.y : endValue.y - startPosY;
|
||||
}
|
||||
Vector2 pos = target.anchoredPosition;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -10,6 +10,20 @@
|
||||
These, as all DOTween43 methods, require Unity 4.3 or later.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOGradientColor(UnityEngine.Material,UnityEngine.Gradient,System.Single)">
|
||||
<summary>Tweens a Material's color using the given gradient
|
||||
(NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="gradient">The gradient to use</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOGradientColor(UnityEngine.Material,UnityEngine.Gradient,System.String,System.Single)">
|
||||
<summary>Tweens a Material's named color property using the given gradient
|
||||
(NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="gradient">The gradient to use</param>
|
||||
<param name="property">The name of the material property to tween (like _Tint or _SpecColor)</param>
|
||||
<param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOColor(UnityEngine.SpriteRenderer,UnityEngine.Color,System.Single)">
|
||||
<summary>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</summary>
|
||||
@ -20,6 +34,12 @@
|
||||
Also stores the spriteRenderer as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOGradientColor(UnityEngine.SpriteRenderer,UnityEngine.Gradient,System.Single)">
|
||||
<summary>Tweens a SpriteRenderer's colors using the given gradient
|
||||
(NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="gradient">The gradient to use</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOMove(UnityEngine.Rigidbody2D,UnityEngine.Vector2,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Rigidbody2D's position to the given value.
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
@ -46,7 +66,8 @@
|
||||
<member name="M:DG.Tweening.ShortcutExtensions43.DOJump(UnityEngine.Rigidbody2D,UnityEngine.Vector2,System.Single,System.Int32,System.Single,System.Boolean)">
|
||||
<summary>Tweens a Rigidbody2D's position to the given value, while also applying a jump effect along the Y axis.
|
||||
Returns a Sequence instead of a Tweener.
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary>
|
||||
Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations.
|
||||
<para>IMPORTANT: a rigidbody2D can't be animated in a jump arc using MovePosition, so the tween will directly set the position</para></summary>
|
||||
<param name="endValue">The end value to reach</param>
|
||||
<param name="jumpPower">Power of the jump (the max height of the jump is represented by this plus the final Y offset)</param>
|
||||
<param name="numJumps">Total number of jumps</param>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -51,6 +51,12 @@
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="endValue">The end value to reach (0 to 1)</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions46.DOGradientColor(UnityEngine.UI.Image,UnityEngine.Gradient,System.Single)">
|
||||
<summary>Tweens an Image's colors using the given gradient
|
||||
(NOTE 1: only uses the colors of the gradient, not the alphas - NOTE 2: creates a Sequence, not a Tweener).
|
||||
Also stores the image as the tween's target so it can be used for filtered operations</summary>
|
||||
<param name="gradient">The gradient to use</param><param name="duration">The duration of the tween</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.ShortcutExtensions46.DOFlexibleSize(UnityEngine.UI.LayoutElement,UnityEngine.Vector2,System.Single,System.Boolean)">
|
||||
<summary>Tweens an LayoutElement's flexibleWidth/Height to the given value.
|
||||
Also stores the LayoutElement as the tween's target so it can be used for filtered operations</summary>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user