1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-20 09:16:02 +08:00

- Added blendable rotate + scale shortcuts

- Fixed IntPlugin not being set for incremental loops when sequenced
This commit is contained in:
Daniele Giardini 2015-03-27 18:05:35 +01:00
parent 41933d5dda
commit 40dbd39b0e
57 changed files with 344 additions and 112 deletions

View File

@ -1021,22 +1021,6 @@
<param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)">
<summary>EXPERIMENTAL BETA: Tweens a Transform's position BY the given value (as if it was set to relative),
in a way that allows other DOBlendableMove tweens to work together on the same target,
instead than fight each other as multiple DOMove would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The end value to reach</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableLocalMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)">
<summary>EXPERIMENTAL BETA: Tweens a Transform's localPosition BY the given value (as if it was set to relative),
in a way that allows other DOBlendableMove tweens to work together on the same target,
instead than fight each other as multiple DOMove would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The end value to reach</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DORotate(UnityEngine.Transform,UnityEngine.Vector3,System.Single,DG.Tweening.RotateMode)">
<summary>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</summary>
@ -1179,6 +1163,45 @@
Defaults to 10, but a value of 5 is usually enough if you don't have dramatic long curves between waypoints</param>
<param name="gizmoColor">The color of the path (shown when gizmos are active in the Play panel and the tween is running)</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)">
<summary>Tweens a Transform's position BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableMove tweens to work together on the same target,
instead than fight each other as multiple DOMove would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableLocalMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)">
<summary>Tweens a Transform's localPosition BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableMove tweens to work together on the same target,
instead than fight each other as multiple DOMove would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableRotateBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,DG.Tweening.RotateMode)">
<summary>EXPERIMENTAL METHOD - Tweens a Transform's rotation BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableRotate tweens to work together on the same target,
instead than fight each other as multiple DORotate would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="mode">Rotation mode</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableLocalRotateBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,DG.Tweening.RotateMode)">
<summary>EXPERIMENTAL METHOD - Tweens a Transform's lcoalRotation BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableRotate tweens to work together on the same target,
instead than fight each other as multiple DORotate would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="mode">Rotation mode</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableScaleBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single)">
<summary>Tweens a Transform's localScale BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableScale tweens to work together on the same target,
instead than fight each other as multiple DOScale would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOComplete(UnityEngine.Component)">
<summary>
Completes all tweens that have this target as a reference

View File

@ -1021,22 +1021,6 @@
<param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)">
<summary>EXPERIMENTAL BETA: Tweens a Transform's position BY the given value (as if it was set to relative),
in a way that allows other DOBlendableMove tweens to work together on the same target,
instead than fight each other as multiple DOMove would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The end value to reach</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableLocalMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)">
<summary>EXPERIMENTAL BETA: Tweens a Transform's localPosition BY the given value (as if it was set to relative),
in a way that allows other DOBlendableMove tweens to work together on the same target,
instead than fight each other as multiple DOMove would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The end value to reach</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DORotate(UnityEngine.Transform,UnityEngine.Vector3,System.Single,DG.Tweening.RotateMode)">
<summary>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</summary>
@ -1179,6 +1163,45 @@
Defaults to 10, but a value of 5 is usually enough if you don't have dramatic long curves between waypoints</param>
<param name="gizmoColor">The color of the path (shown when gizmos are active in the Play panel and the tween is running)</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)">
<summary>Tweens a Transform's position BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableMove tweens to work together on the same target,
instead than fight each other as multiple DOMove would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableLocalMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)">
<summary>Tweens a Transform's localPosition BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableMove tweens to work together on the same target,
instead than fight each other as multiple DOMove would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableRotateBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,DG.Tweening.RotateMode)">
<summary>EXPERIMENTAL METHOD - Tweens a Transform's rotation BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableRotate tweens to work together on the same target,
instead than fight each other as multiple DORotate would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="mode">Rotation mode</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableLocalRotateBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,DG.Tweening.RotateMode)">
<summary>EXPERIMENTAL METHOD - Tweens a Transform's lcoalRotation BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableRotate tweens to work together on the same target,
instead than fight each other as multiple DORotate would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="mode">Rotation mode</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableScaleBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single)">
<summary>Tweens a Transform's localScale BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableScale tweens to work together on the same target,
instead than fight each other as multiple DOScale would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOComplete(UnityEngine.Component)">
<summary>
Completes all tweens that have this target as a reference

View File

@ -1021,22 +1021,6 @@
<param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)">
<summary>EXPERIMENTAL BETA: Tweens a Transform's position BY the given value (as if it was set to relative),
in a way that allows other DOBlendableMove tweens to work together on the same target,
instead than fight each other as multiple DOMove would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The end value to reach</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableLocalMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)">
<summary>EXPERIMENTAL BETA: Tweens a Transform's localPosition BY the given value (as if it was set to relative),
in a way that allows other DOBlendableMove tweens to work together on the same target,
instead than fight each other as multiple DOMove would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The end value to reach</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DORotate(UnityEngine.Transform,UnityEngine.Vector3,System.Single,DG.Tweening.RotateMode)">
<summary>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</summary>
@ -1179,6 +1163,45 @@
Defaults to 10, but a value of 5 is usually enough if you don't have dramatic long curves between waypoints</param>
<param name="gizmoColor">The color of the path (shown when gizmos are active in the Play panel and the tween is running)</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)">
<summary>Tweens a Transform's position BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableMove tweens to work together on the same target,
instead than fight each other as multiple DOMove would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableLocalMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)">
<summary>Tweens a Transform's localPosition BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableMove tweens to work together on the same target,
instead than fight each other as multiple DOMove would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableRotateBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,DG.Tweening.RotateMode)">
<summary>EXPERIMENTAL METHOD - Tweens a Transform's rotation BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableRotate tweens to work together on the same target,
instead than fight each other as multiple DORotate would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="mode">Rotation mode</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableLocalRotateBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,DG.Tweening.RotateMode)">
<summary>EXPERIMENTAL METHOD - Tweens a Transform's lcoalRotation BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableRotate tweens to work together on the same target,
instead than fight each other as multiple DORotate would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="mode">Rotation mode</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableScaleBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single)">
<summary>Tweens a Transform's localScale BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableScale tweens to work together on the same target,
instead than fight each other as multiple DOScale would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOComplete(UnityEngine.Component)">
<summary>
Completes all tweens that have this target as a reference

View File

@ -1,4 +1,8 @@
fileFormatVersion: 2
guid: 32d3af87ee00b2540b93b3d175025be1
timeCreated: 1427447719
licenseType: Pro
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,4 +1,8 @@
fileFormatVersion: 2
guid: 75fba9607a513b64984db6d29f41986c
timeCreated: 1427447735
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 8d96bf24046f5a74fbc20d52d55cbc88
labels:
- d6
timeCreated: 1427466480
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -4,29 +4,80 @@ using DG.Tweening;
public class BlendableTweens : BrainBase
{
public bool addBlendable = true;
public bool from;
public bool fromBlendable;
public bool repeatBlendable = true;
public RotateMode rotationMode;
public Ease ease = Ease.OutQuad;
public Transform[] targets;
public Transform nonBlendableT;
Vector3[] startPositions;
IEnumerator Start()
{
startPositions = new Vector3[targets.Length];
startPositions = new Vector3[2];
startPositions[0] = targets[0].position;
startPositions[1] = targets[1].position + new Vector3(3, 3, 0);
yield return new WaitForSeconds(0.6f);
targets[0].DOBlendableMoveBy(new Vector3(3, 3, 0), 3).SetAutoKill(false).Pause();
targets[0].DOBlendableMoveBy(new Vector3(-3, 0, 0), 1f).SetLoops(3, LoopType.Yoyo).SetAutoKill(false).Pause();
// Same as above but using From
targets[1].DOBlendableMoveBy(new Vector3(3, 3, 0), 3).From().SetAutoKill(false).Pause();
targets[1].DOBlendableMoveBy(new Vector3(-3, 0, 0), 1f).SetLoops(3, LoopType.Yoyo).SetAutoKill(false).Pause();
Vector3 to;
float duration;
int loops;
// Move
duration = 3;
to = new Vector3(3, 3, 0);
startPositions[1] = targets[0].position + to;
if (from) targets[0].DOBlendableMoveBy(to, duration).From().SetEase(ease).SetAutoKill(false).Pause();
else targets[0].DOBlendableMoveBy(to, duration).SetEase(ease).SetAutoKill(false).Pause();
if (addBlendable) {
to = new Vector3(-3, 0, 0);
duration = repeatBlendable ? 1 : 3;
loops = repeatBlendable ? 3 : 1;
if (fromBlendable) targets[0].DOBlendableMoveBy(to, duration).From().SetEase(ease).SetLoops(loops, LoopType.Yoyo).SetAutoKill(false).Pause();
else targets[0].DOBlendableMoveBy(to, duration).SetEase(ease).SetLoops(loops, LoopType.Yoyo).SetAutoKill(false).Pause();
}
// Scale
duration = 3;
to = new Vector3(0, 1, 0);
if (from) targets[1].DOBlendableScaleBy(to, duration).From().SetEase(ease).SetAutoKill(false).Pause();
else targets[1].DOBlendableScaleBy(to, duration).SetEase(ease).SetAutoKill(false).Pause();
if (addBlendable) {
to = new Vector3(1, 0, 0);
duration = repeatBlendable ? 1 : 3;
loops = repeatBlendable ? 3 : 1;
if (fromBlendable) targets[1].DOBlendableScaleBy(to, duration).From().SetEase(ease).SetLoops(loops, LoopType.Yoyo).SetAutoKill(false).Pause();
else targets[1].DOBlendableScaleBy(to, duration).SetEase(ease).SetLoops(loops, LoopType.Yoyo).SetAutoKill(false).Pause();
}
// Rotate
duration = 3;
to = new Vector3(0, 90, 0);
if (from) targets[2].DOBlendableRotateBy(to, duration, rotationMode).From().SetEase(ease).SetAutoKill(false).Pause();
else targets[2].DOBlendableRotateBy(to, duration, rotationMode).SetEase(ease).SetAutoKill(false).Pause();
if (addBlendable) {
to = new Vector3(90, 0, 0);
duration = repeatBlendable ? 1 : 3;
loops = repeatBlendable ? 3 : 1;
if (fromBlendable) targets[2].DOBlendableRotateBy(to, duration, rotationMode).From().SetEase(ease).SetLoops(loops, LoopType.Yoyo).SetAutoKill(false).Pause();
else targets[2].DOBlendableRotateBy(to, duration, rotationMode).SetEase(ease).SetLoops(loops, LoopType.Yoyo).SetAutoKill(false).Pause();
}
// Non blendable for comparisons
duration = 3;
to = new Vector3(0, 90, 0);
if (from) nonBlendableT.DORotate(to, duration, rotationMode).From(true).SetEase(ease).SetAutoKill(false).Pause();
else nonBlendableT.DORotate(to, duration, rotationMode).SetEase(ease).SetAutoKill(false).Pause();
}
void OnGUI()
{
if (GUILayout.Button("Toggle Pause")) DOTween.TogglePauseAll();
if (GUILayout.Button("Restart")) DOTween.RestartAll();
if (GUILayout.Button("Rewind")) DOTween.RewindAll();
if (GUILayout.Button("Complete")) DOTween.CompleteAll();
if (GUILayout.Button("Flip")) DOTween.FlipAll();
}

View File

@ -17,12 +17,10 @@ public class TempTests : BrainBase
int count;
Tween t;
IEnumerator Start()
{
yield return new WaitForSeconds(0.6f);
t = target.DOPath(waypoints, 5, PathType.CatmullRom).SetEase(easeType).SetLoops(-1);
target.DOPath(waypoints, 5, PathType.CatmullRom).SetEase(easeType).SetLoops(-1);
}
}

View File

@ -27,5 +27,13 @@ namespace DG.Tweening.Core
t.isFromAllowed = false;
return t;
}
// Sets the tween as blendable
internal static TweenerCore<T1, T2, TPlugOptions> Blendable<T1, T2, TPlugOptions>(this TweenerCore<T1, T2, TPlugOptions> t)
where TPlugOptions : struct
{
t.isBlendable = true;
return t;
}
}
}

View File

@ -21,7 +21,7 @@ namespace DG.Tweening
public class DOTween
{
/// <summary>DOTween's version</summary>
public static readonly string Version = "1.0.351";
public static readonly string Version = "1.0.401";
///////////////////////////////////////////////
// Options ////////////////////////////////////

View File

@ -50,6 +50,10 @@ namespace DG.Tweening.Plugins
public override void EvaluateAndApply(NoOptions options, Tween t, bool isRelative, DOGetter<int> getter, DOSetter<int> setter, float elapsed, int startValue, int changeValue, float duration, bool usingInversePosition)
{
if (t.loopType == LoopType.Incremental) startValue += changeValue * (t.isComplete ? t.completedLoops - 1 : t.completedLoops);
if (t.isSequenced && t.sequenceParent.loopType == LoopType.Incremental) {
startValue += changeValue * (t.loopType == LoopType.Incremental ? t.loops : 1)
* (t.sequenceParent.isComplete ? t.sequenceParent.completedLoops - 1 : t.sequenceParent.completedLoops);
}
setter((int)Math.Round(startValue + changeValue * EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod)));
}

View File

@ -379,40 +379,6 @@ namespace DG.Tweening
.SetOptions(AxisConstraint.Z, snapping).SetTarget(target);
}
/// <summary>EXPERIMENTAL BETA: Tweens a Transform's position BY the given value (as if it was set to relative),
/// in a way that allows other DOBlendableMove tweens to work together on the same target,
/// instead than fight each other as multiple DOMove would do.
/// Also stores the transform as the tween's target so it can be used for filtered operations</summary>
/// <param name="byValue">The end value to reach</param><param name="duration">The duration of the tween</param>
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
public static Tweener DOBlendableMoveBy(this Transform target, Vector3 byValue, float duration, bool snapping = false)
{
Vector3 to = Vector3.zero;
return DOTween.To(() => to, x => {
Vector3 diff = x - to;
to = x;
target.position += diff;
}, byValue, duration)
.SetOptions(snapping).SetTarget(target);
}
/// <summary>EXPERIMENTAL BETA: Tweens a Transform's localPosition BY the given value (as if it was set to relative),
/// in a way that allows other DOBlendableMove tweens to work together on the same target,
/// instead than fight each other as multiple DOMove would do.
/// Also stores the transform as the tween's target so it can be used for filtered operations</summary>
/// <param name="byValue">The end value to reach</param><param name="duration">The duration of the tween</param>
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
public static Tweener DOBlendableLocalMoveBy(this Transform target, Vector3 byValue, float duration, bool snapping = false)
{
Vector3 to = Vector3.zero;
return DOTween.To(() => to, x => {
Vector3 diff = x - to;
to = x;
target.localPosition += diff;
}, byValue, duration)
.SetOptions(snapping).SetTarget(target);
}
/// <summary>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</summary>
/// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
@ -663,6 +629,98 @@ namespace DG.Tweening
return t;
}
#region Blendables
/// <summary>Tweens a Transform's position BY the given value (as if you chained a <code>SetRelative</code>),
/// in a way that allows other DOBlendableMove tweens to work together on the same target,
/// instead than fight each other as multiple DOMove would do.
/// Also stores the transform as the tween's target so it can be used for filtered operations</summary>
/// <param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
public static Tweener DOBlendableMoveBy(this Transform target, Vector3 byValue, float duration, bool snapping = false)
{
Vector3 to = Vector3.zero;
return DOTween.To(() => to, x => {
Vector3 diff = x - to;
to = x;
target.position += diff;
}, byValue, duration)
.Blendable().SetOptions(snapping).SetTarget(target);
}
/// <summary>Tweens a Transform's localPosition BY the given value (as if you chained a <code>SetRelative</code>),
/// in a way that allows other DOBlendableMove tweens to work together on the same target,
/// instead than fight each other as multiple DOMove would do.
/// Also stores the transform as the tween's target so it can be used for filtered operations</summary>
/// <param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
public static Tweener DOBlendableLocalMoveBy(this Transform target, Vector3 byValue, float duration, bool snapping = false)
{
Vector3 to = Vector3.zero;
return DOTween.To(() => to, x => {
Vector3 diff = x - to;
to = x;
target.localPosition += diff;
}, byValue, duration)
.Blendable().SetOptions(snapping).SetTarget(target);
}
/// <summary>EXPERIMENTAL METHOD - Tweens a Transform's rotation BY the given value (as if you chained a <code>SetRelative</code>),
/// in a way that allows other DOBlendableRotate tweens to work together on the same target,
/// instead than fight each other as multiple DORotate would do.
/// Also stores the transform as the tween's target so it can be used for filtered operations</summary>
/// <param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
/// <param name="mode">Rotation mode</param>
public static Tweener DOBlendableRotateBy(this Transform target, Vector3 byValue, float duration, RotateMode mode = RotateMode.Fast)
{
Quaternion to = target.rotation;
TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => to, x => {
Quaternion diff = x * Quaternion.Inverse(to);
to = x;
target.rotation = target.rotation * Quaternion.Inverse(target.rotation) * diff * target.rotation;
}, byValue, duration)
.Blendable().SetTarget(target);
t.plugOptions.rotateMode = mode;
return t;
}
/// <summary>EXPERIMENTAL METHOD - Tweens a Transform's lcoalRotation BY the given value (as if you chained a <code>SetRelative</code>),
/// in a way that allows other DOBlendableRotate tweens to work together on the same target,
/// instead than fight each other as multiple DORotate would do.
/// Also stores the transform as the tween's target so it can be used for filtered operations</summary>
/// <param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
/// <param name="mode">Rotation mode</param>
public static Tweener DOBlendableLocalRotateBy(this Transform target, Vector3 byValue, float duration, RotateMode mode = RotateMode.Fast)
{
Quaternion to = target.rotation;
TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => to, x => {
Quaternion diff = x * Quaternion.Inverse(to);
to = x;
target.rotation = target.rotation * Quaternion.Inverse(target.rotation) * diff * target.rotation;
}, byValue, duration)
.Blendable().SetTarget(target);
t.plugOptions.rotateMode = mode;
return t;
}
/// <summary>Tweens a Transform's localScale BY the given value (as if you chained a <code>SetRelative</code>),
/// in a way that allows other DOBlendableScale tweens to work together on the same target,
/// instead than fight each other as multiple DOScale would do.
/// Also stores the transform as the tween's target so it can be used for filtered operations</summary>
/// <param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
public static Tweener DOBlendableScaleBy(this Transform target, Vector3 byValue, float duration)
{
Vector3 to = Vector3.zero;
return DOTween.To(() => to, x => {
Vector3 diff = x - to;
to = x;
target.localScale += diff;
}, byValue, duration)
.Blendable().SetTarget(target);
}
#endregion
#endregion
// ===================================================================================

View File

@ -54,6 +54,7 @@ namespace DG.Tweening
// Fixed after creation
internal bool isFrom; // Used to prevent settings like isRelative from being applied on From tweens
internal bool isBlendable; // Set by blendable tweens, prevents isRelative to be applied
internal bool isRecyclable;
internal bool isSpeedBased;
internal bool autoKill;
@ -114,6 +115,7 @@ namespace DG.Tweening
target = null;
isFrom = false;
isBlendable = false;
isSpeedBased = false;
duration = 0;
loops = 1;

View File

@ -507,7 +507,8 @@ namespace DG.Tweening
if (!t.active || t.creationLocked || !t.isFromAllowed) return t;
t.isFrom = true;
t.SetFrom(isRelative);
if (!isRelative) t.SetFrom(false);
else t.SetFrom(!t.isBlendable);
return t;
}
@ -527,7 +528,7 @@ namespace DG.Tweening
/// <para>Has no effect on Sequences or if the tween has already started</para></summary>
public static T SetRelative<T>(this T t) where T : Tween
{
if (!t.active || t.creationLocked || t.isFrom) return t;
if (!t.active || t.creationLocked || t.isFrom || t.isBlendable) return t;
t.isRelative = true;
return t;
@ -537,7 +538,7 @@ namespace DG.Tweening
/// <para>Has no effect on Sequences or if the tween has already started</para></summary>
public static T SetRelative<T>(this T t, bool isRelative) where T : Tween
{
if (!t.active || t.creationLocked || t.isFrom) return t;
if (!t.active || t.creationLocked || t.isFrom || t.isBlendable) return t;
t.isRelative = isRelative;
return t;

View File

@ -1021,22 +1021,6 @@
<param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)">
<summary>EXPERIMENTAL BETA: Tweens a Transform's position BY the given value (as if it was set to relative),
in a way that allows other DOBlendableMove tweens to work together on the same target,
instead than fight each other as multiple DOMove would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The end value to reach</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableLocalMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)">
<summary>EXPERIMENTAL BETA: Tweens a Transform's localPosition BY the given value (as if it was set to relative),
in a way that allows other DOBlendableMove tweens to work together on the same target,
instead than fight each other as multiple DOMove would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The end value to reach</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DORotate(UnityEngine.Transform,UnityEngine.Vector3,System.Single,DG.Tweening.RotateMode)">
<summary>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</summary>
@ -1179,6 +1163,45 @@
Defaults to 10, but a value of 5 is usually enough if you don't have dramatic long curves between waypoints</param>
<param name="gizmoColor">The color of the path (shown when gizmos are active in the Play panel and the tween is running)</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)">
<summary>Tweens a Transform's position BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableMove tweens to work together on the same target,
instead than fight each other as multiple DOMove would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableLocalMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)">
<summary>Tweens a Transform's localPosition BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableMove tweens to work together on the same target,
instead than fight each other as multiple DOMove would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableRotateBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,DG.Tweening.RotateMode)">
<summary>EXPERIMENTAL METHOD - Tweens a Transform's rotation BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableRotate tweens to work together on the same target,
instead than fight each other as multiple DORotate would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="mode">Rotation mode</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableLocalRotateBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,DG.Tweening.RotateMode)">
<summary>EXPERIMENTAL METHOD - Tweens a Transform's lcoalRotation BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableRotate tweens to work together on the same target,
instead than fight each other as multiple DORotate would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="mode">Rotation mode</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableScaleBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single)">
<summary>Tweens a Transform's localScale BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableScale tweens to work together on the same target,
instead than fight each other as multiple DOScale would do.
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOComplete(UnityEngine.Component)">
<summary>
Completes all tweens that have this target as a reference

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.