mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2025-12-20 09:16:02 +08:00
[BUGFIX] Applied DOJump fix to DOJumpAnchorPos
This commit is contained in:
parent
af8fd4db95
commit
dfb425dfe3
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.
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.
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -32,7 +32,7 @@ namespace DG.Tweening
|
||||
public class DOTween
|
||||
{
|
||||
/// <summary>DOTween's version</summary>
|
||||
public static readonly string Version = "1.1.750";
|
||||
public static readonly string Version = "1.1.755";
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// Options ////////////////////////////////////
|
||||
|
||||
@ -379,16 +379,21 @@ namespace DG.Tweening
|
||||
public static Sequence DOJumpAnchorPos(this RectTransform target, Vector2 endValue, float jumpPower, int numJumps, float duration, bool snapping = false)
|
||||
{
|
||||
if (numJumps < 1) numJumps = 1;
|
||||
float startPosY = target.anchoredPosition.y;
|
||||
float startPosY = 0;
|
||||
float offsetY = -1;
|
||||
bool offsetYSet = false;
|
||||
Sequence s = DOTween.Sequence()
|
||||
.Append(DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(endValue.x, 0), duration)
|
||||
|
||||
// Separate Y Tween so we can elaborate elapsedPercentage on that insted of on the Sequence
|
||||
// (in case users add a delay or other elements to the Sequence)
|
||||
Sequence s = DOTween.Sequence();
|
||||
Tween yTween = DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(0, jumpPower), duration / (numJumps * 2))
|
||||
.SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad).SetRelative()
|
||||
.SetLoops(numJumps * 2, LoopType.Yoyo)
|
||||
.OnStart(()=> startPosY = target.anchoredPosition.y);
|
||||
s.Append(DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(endValue.x, 0), duration)
|
||||
.SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear)
|
||||
).Join(DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(0, jumpPower), duration / (numJumps * 2))
|
||||
.SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad)
|
||||
.SetLoops(numJumps * 2, LoopType.Yoyo).SetRelative()
|
||||
).SetTarget(target).SetEase(DOTween.defaultEaseType);
|
||||
).Join(yTween)
|
||||
.SetTarget(target).SetEase(DOTween.defaultEaseType);
|
||||
s.OnUpdate(() => {
|
||||
if (!offsetYSet) {
|
||||
offsetYSet = true;
|
||||
@ -399,6 +404,28 @@ namespace DG.Tweening
|
||||
target.anchoredPosition = pos;
|
||||
});
|
||||
return s;
|
||||
|
||||
// if (numJumps < 1) numJumps = 1;
|
||||
// float startPosY = target.anchoredPosition.y;
|
||||
// float offsetY = -1;
|
||||
// bool offsetYSet = false;
|
||||
// Sequence s = DOTween.Sequence()
|
||||
// .Append(DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(endValue.x, 0), duration)
|
||||
// .SetOptions(AxisConstraint.X, snapping).SetEase(Ease.Linear)
|
||||
// ).Join(DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(0, jumpPower), duration / (numJumps * 2))
|
||||
// .SetOptions(AxisConstraint.Y, snapping).SetEase(Ease.OutQuad)
|
||||
// .SetLoops(numJumps * 2, LoopType.Yoyo).SetRelative()
|
||||
// ).SetTarget(target).SetEase(DOTween.defaultEaseType);
|
||||
// s.OnUpdate(() => {
|
||||
// if (!offsetYSet) {
|
||||
// offsetYSet = true;
|
||||
// offsetY = s.isRelative ? endValue.y : endValue.y - startPosY;
|
||||
// }
|
||||
// Vector2 pos = target.anchoredPosition;
|
||||
// pos.y += DOVirtual.EasedValue(0, offsetY, s.ElapsedDirectionalPercentage(), Ease.OutQuad);
|
||||
// target.anchoredPosition = pos;
|
||||
// });
|
||||
// return s;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
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.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user