1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2026-02-04 14:24:55 +08:00

Hyper-compatible version fix which allows Color32 to work correctly

+ Fix to ScrollRect.DONormalizedPos not working correctly with hyper-compatible mode
This commit is contained in:
Demigiant 2016-03-12 15:42:09 +01:00
parent 9fb0daae6d
commit f3a549436b
46 changed files with 56 additions and 55 deletions

View File

@ -13,7 +13,7 @@ public class FollowTargetUntilReached : MonoBehaviour
// In this case, when the target is reached the tween will be // In this case, when the target is reached the tween will be
// automatically killed and the following will stop // automatically killed and the following will stop
Vector3 prevTargetPos = targetToFollow.position; Vector3 prevTargetPos = targetToFollow.position;
Tweener followTween = follower.DOMove(targetToFollow.position, 2); Tweener followTween = follower.DOMove(targetToFollow.position, 4);
followTween.OnUpdate(()=> { followTween.OnUpdate(()=> {
if (prevTargetPos != targetToFollow.position) { if (prevTargetPos != targetToFollow.position) {
prevTargetPos = targetToFollow.position; prevTargetPos = targetToFollow.position;

View File

@ -10,31 +10,11 @@ using UnityEngine.UI;
public class TempTests : BrainBase public class TempTests : BrainBase
{ {
public Transform target; public Color32 color;
public float InitialDelay = 1;
public float ExpandDelay = 2;
public float ExpandSpeed = 0.1f;
public float RetractDelay = 2;
public float RetractSpeed = 2;
float time;
Sequence s;
// Use this for initialization
void Start () void Start ()
{ {
time = Time.realtimeSinceStartup; DOTween.To(()=> color, x=> color = x, Color.red, 2)
.OnUpdate(()=> Debug.Log(color));
s = DOTween.Sequence();
s.Append(target.DOMove(target.position + new Vector3(0, 0.1f, 0),0.1f).SetDelay(InitialDelay));
s.Append(target.DOMove(target.position + new Vector3(0, 1, 0), ExpandSpeed).SetDelay(ExpandDelay));
s.Append(target.DOMove(target.position - new Vector3(0, 1.1f, 0), RetractSpeed).SetDelay(RetractDelay));
s.SetLoops(-1, LoopType.Restart).OnStepComplete(Step);
}
void Step()
{
Debug.Log(Time.realtimeSinceStartup - time);
time = Time.realtimeSinceStartup;
} }
} }

View File

@ -21,10 +21,20 @@ namespace DG.Tweening.Core.Surrogates
return v.value; return v.value;
} }
public static implicit operator Color32(ColorWrapper v)
{
return v.value;
}
public static implicit operator ColorWrapper(Color v) public static implicit operator ColorWrapper(Color v)
{ {
return new ColorWrapper(v); return new ColorWrapper(v);
} }
public static implicit operator ColorWrapper(Color32 v)
{
return new ColorWrapper(v);
}
} }
} }
#endif #endif

View File

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

View File

@ -8,6 +8,9 @@ using DG.Tweening.Core;
using DG.Tweening.Core.Enums; using DG.Tweening.Core.Enums;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
#if COMPATIBLE
using DG.Tweening.Core.Surrogates;
#endif
namespace DG.Tweening namespace DG.Tweening
{ {
@ -356,11 +359,19 @@ namespace DG.Tweening
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
public static Tweener DONormalizedPos(this ScrollRect target, Vector2 endValue, float duration, bool snapping = false) public static Tweener DONormalizedPos(this ScrollRect target, Vector2 endValue, float duration, bool snapping = false)
{ {
#if COMPATIBLE
return DOTween.To(() => new Vector2Wrapper(target.horizontalNormalizedPosition, target.verticalNormalizedPosition),
x => {
target.horizontalNormalizedPosition = x.value.x;
target.verticalNormalizedPosition = x.value.y;
}, endValue, duration)
#else
return DOTween.To(() => new Vector2(target.horizontalNormalizedPosition, target.verticalNormalizedPosition), return DOTween.To(() => new Vector2(target.horizontalNormalizedPosition, target.verticalNormalizedPosition),
x => { x => {
target.horizontalNormalizedPosition = x.x; target.horizontalNormalizedPosition = x.x;
target.verticalNormalizedPosition = x.y; target.verticalNormalizedPosition = x.y;
}, endValue, duration) }, endValue, duration)
#endif
.SetOptions(snapping).SetTarget(target); .SetOptions(snapping).SetTarget(target);
} }
/// <summary>Tweens a ScrollRect's horizontalNormalizedPosition to the given value. /// <summary>Tweens a ScrollRect's horizontalNormalizedPosition to the given value.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.