1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-20 09:16:02 +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
{ {
@ -17,9 +20,9 @@ namespace DG.Tweening
/// </summary> /// </summary>
public static class ShortcutExtensions46 public static class ShortcutExtensions46
{ {
#region Unity UI #region Unity UI
#region CanvasGroup #region CanvasGroup
/// <summary>Tweens a CanvasGroup's alpha color to the given value. /// <summary>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</summary> /// Also stores the canvasGroup as the tween's target so it can be used for filtered operations</summary>
@ -30,9 +33,9 @@ namespace DG.Tweening
.SetTarget(target); .SetTarget(target);
} }
#endregion #endregion
#region Graphic #region Graphic
/// <summary>Tweens an Graphic's color to the given value. /// <summary>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</summary> /// Also stores the image as the tween's target so it can be used for filtered operations</summary>
@ -51,9 +54,9 @@ namespace DG.Tweening
.SetTarget(target); .SetTarget(target);
} }
#endregion #endregion
#region Image #region Image
/// <summary>Tweens an Image's color to the given value. /// <summary>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</summary> /// Also stores the image as the tween's target so it can be used for filtered operations</summary>
@ -106,9 +109,9 @@ namespace DG.Tweening
return s; return s;
} }
#endregion #endregion
#region LayoutElement #region LayoutElement
/// <summary>Tweens an LayoutElement's flexibleWidth/Height to the given value. /// <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> /// Also stores the LayoutElement as the tween's target so it can be used for filtered operations</summary>
@ -164,9 +167,9 @@ namespace DG.Tweening
.SetOptions(snapping).SetTarget(target); .SetOptions(snapping).SetTarget(target);
} }
#endregion #endregion
#region Outline #region Outline
/// <summary>Tweens a Outline's effectColor to the given value. /// <summary>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</summary> /// Also stores the Outline as the tween's target so it can be used for filtered operations</summary>
@ -194,9 +197,9 @@ namespace DG.Tweening
.SetTarget(target); .SetTarget(target);
} }
#endregion #endregion
#region RectTransform #region RectTransform
/// <summary>Tweens a RectTransform's anchoredPosition to the given value. /// <summary>Tweens a RectTransform's anchoredPosition to the given value.
/// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary> /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
@ -309,7 +312,7 @@ namespace DG.Tweening
.SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetShake).SetOptions(snapping); .SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetShake).SetOptions(snapping);
} }
#region Special #region Special
/// <summary>Tweens a RectTransform's anchoredPosition to the given value, while also applying a jump effect along the Y axis. /// <summary>Tweens a RectTransform's anchoredPosition to the given value, while also applying a jump effect along the Y axis.
/// Returns a Sequence instead of a Tweener. /// Returns a Sequence instead of a Tweener.
@ -344,11 +347,11 @@ namespace DG.Tweening
return s; return s;
} }
#endregion #endregion
#endregion #endregion
#region ScrollRect #region ScrollRect
/// <summary>Tweens a ScrollRect's horizontal/verticalNormalizedPosition to the given value. /// <summary>Tweens a ScrollRect's horizontal/verticalNormalizedPosition to the given value.
/// Also stores the ScrollRect as the tween's target so it can be used for filtered operations</summary> /// Also stores the ScrollRect as the tween's target so it can be used for filtered operations</summary>
@ -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.
@ -382,9 +393,9 @@ namespace DG.Tweening
.SetOptions(snapping).SetTarget(target); .SetOptions(snapping).SetTarget(target);
} }
#endregion #endregion
#region Slider #region Slider
/// <summary>Tweens a Slider's value to the given value. /// <summary>Tweens a Slider's value to the given value.
/// Also stores the Slider as the tween's target so it can be used for filtered operations</summary> /// Also stores the Slider as the tween's target so it can be used for filtered operations</summary>
@ -396,9 +407,9 @@ namespace DG.Tweening
.SetOptions(snapping).SetTarget(target); .SetOptions(snapping).SetTarget(target);
} }
#endregion #endregion
#region Text #region Text
/// <summary>Tweens a Text's color to the given value. /// <summary>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</summary> /// Also stores the Text as the tween's target so it can be used for filtered operations</summary>
@ -433,13 +444,13 @@ namespace DG.Tweening
.SetTarget(target); .SetTarget(target);
} }
#endregion #endregion
#endregion #endregion
#region Blendables #region Blendables
#region Graphic #region Graphic
/// <summary>Tweens a Graphic's color to the given value, /// <summary>Tweens a Graphic's color to the given value,
/// in a way that allows other DOBlendableColor tweens to work together on the same target, /// in a way that allows other DOBlendableColor tweens to work together on the same target,
@ -462,9 +473,9 @@ namespace DG.Tweening
.Blendable().SetTarget(target); .Blendable().SetTarget(target);
} }
#endregion #endregion
#region Image #region Image
/// <summary>Tweens a Image's color to the given value, /// <summary>Tweens a Image's color to the given value,
/// in a way that allows other DOBlendableColor tweens to work together on the same target, /// in a way that allows other DOBlendableColor tweens to work together on the same target,
@ -487,9 +498,9 @@ namespace DG.Tweening
.Blendable().SetTarget(target); .Blendable().SetTarget(target);
} }
#endregion #endregion
#region Text #region Text
/// <summary>Tweens a Text's color BY the given value, /// <summary>Tweens a Text's color BY the given value,
/// in a way that allows other DOBlendableColor tweens to work together on the same target, /// in a way that allows other DOBlendableColor tweens to work together on the same target,
@ -512,8 +523,8 @@ namespace DG.Tweening
.Blendable().SetTarget(target); .Blendable().SetTarget(target);
} }
#endregion #endregion
#endregion #endregion
} }
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.