mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2025-12-20 09:16:02 +08:00
Fixed decreasing uint tweens not working correctly
This commit is contained in:
parent
d151ff5679
commit
49678b434c
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.
Binary file not shown.
@ -16,7 +16,7 @@ public class RichText : BrainBase
|
||||
|
||||
TweenParams tp = new TweenParams().SetEase(Ease.Linear);
|
||||
tp.SetSpeedBased(speedBased);
|
||||
txtRichA.DOText("This is a <color=#ff0000>colored <color=#00ff00>text</color></color> and normal text", duration, true, scrambleMode).SetAs(tp);
|
||||
txtRichA.DOText("This is a <color=#ff0000>colored <color=#00ff00>text</color></color> and normal text. And this is a minor sign: <", duration, true, scrambleMode).SetAs(tp);
|
||||
txtA.DOText("This is a colored text and normal text", duration, true, scrambleMode).SetAs(tp);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@ -10,12 +10,10 @@ using UnityEngine.UI;
|
||||
|
||||
public class TempTests : BrainBase
|
||||
{
|
||||
public RectTransform target;
|
||||
public uint test = 1000;
|
||||
public uint to = 0;
|
||||
|
||||
IEnumerator Start ()
|
||||
{
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
target.DOPivot(Vector2.zero, 2);
|
||||
void Start () {
|
||||
DOTween.To(()=> test, x=> test = x, to, 2.0f).OnUpdate(()=> Debug.Log("1000 to 0 > " + test));
|
||||
}
|
||||
}
|
||||
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.290";
|
||||
public static readonly string Version = "1.1.300";
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// Options ////////////////////////////////////
|
||||
@ -304,7 +304,7 @@ namespace DG.Tweening
|
||||
/// <para>Example usage with lambda:</para><code>x=> myProperty = x</code></param>
|
||||
/// <param name="endValue">The end value to reach</param><param name="duration">The tween's duration</param>
|
||||
public static Tweener To(DOGetter<uint> getter, DOSetter<uint> setter, uint endValue, float duration)
|
||||
{ return ApplyTo<uint, uint, NoOptions>(getter, setter, endValue, duration); }
|
||||
{ return ApplyTo<uint, uint, UintOptions>(getter, setter, endValue, duration); }
|
||||
/// <summary>Tweens a property or field to the given value using default plugins</summary>
|
||||
/// <param name="getter">A getter for the field or property to tween.
|
||||
/// <para>Example usage with lambda:</para><code>()=> myProperty</code></param>
|
||||
|
||||
@ -98,6 +98,7 @@
|
||||
<Compile Include="Plugins\LongPlugin.cs" />
|
||||
<Compile Include="Plugins\Options\PathOptions.cs" />
|
||||
<Compile Include="Plugins\Options\QuaternionOptions.cs" />
|
||||
<Compile Include="Plugins\Options\UintOptions.cs" />
|
||||
<Compile Include="Plugins\Options\Vector3ArrayOptions.cs" />
|
||||
<Compile Include="Plugins\QuaternionWrapperPlugin.cs" />
|
||||
<Compile Include="Plugins\UlongPlugin.cs" />
|
||||
|
||||
13
_DOTween.Assembly/DOTween/Plugins/Options/UintOptions.cs
Normal file
13
_DOTween.Assembly/DOTween/Plugins/Options/UintOptions.cs
Normal file
@ -0,0 +1,13 @@
|
||||
// Author: Daniele Giardini - http://www.demigiant.com
|
||||
// Created: 2016/05/30 13:00
|
||||
// License Copyright (c) Daniele Giardini
|
||||
// This work is subject to the terms at http://dotween.demigiant.com/license.php
|
||||
|
||||
#pragma warning disable 1591
|
||||
namespace DG.Tweening.Plugins.Options
|
||||
{
|
||||
public struct UintOptions
|
||||
{
|
||||
public bool isNegativeChangeValue; // Necessary because uints can't obviously be negative
|
||||
}
|
||||
}
|
||||
@ -130,7 +130,7 @@ namespace DG.Tweening.Plugins
|
||||
int fullLen = value.Length;
|
||||
int i;
|
||||
for (i = 0; i < length; ++i) {
|
||||
Char c = value[i];
|
||||
char c = value[i];
|
||||
if (c == '<') {
|
||||
bool hadOpenTag = hasOpenTag;
|
||||
char nextChar = value[i + 1];
|
||||
@ -141,7 +141,7 @@ namespace DG.Tweening.Plugins
|
||||
Match m = Regex.Match(s, tagMatch);
|
||||
if (m.Success) {
|
||||
if (!hasOpenTag && !hadOpenTag) {
|
||||
// We have a closing tag without an opening tag, try to find previous correct opening tag an apply it
|
||||
// We have a closing tag without an opening tag, try to find previous correct opening tag and apply it
|
||||
char closingTagFirstChar = value[i + 1];
|
||||
char[] openingTagLookouts;
|
||||
if (closingTagFirstChar == 'c') openingTagLookouts = new[] { '#', 'c' };
|
||||
|
||||
@ -10,15 +10,16 @@ using DG.Tweening.Core.Easing;
|
||||
using DG.Tweening.Core.Enums;
|
||||
using DG.Tweening.Plugins.Core;
|
||||
using DG.Tweening.Plugins.Options;
|
||||
using UnityEngine;
|
||||
|
||||
#pragma warning disable 1591
|
||||
namespace DG.Tweening.Plugins
|
||||
{
|
||||
public class UintPlugin : ABSTweenPlugin<uint, uint, NoOptions>
|
||||
public class UintPlugin : ABSTweenPlugin<uint, uint, UintOptions>
|
||||
{
|
||||
public override void Reset(TweenerCore<uint, uint, NoOptions> t) { }
|
||||
public override void Reset(TweenerCore<uint, uint, UintOptions> t) { }
|
||||
|
||||
public override void SetFrom(TweenerCore<uint, uint, NoOptions> t, bool isRelative)
|
||||
public override void SetFrom(TweenerCore<uint, uint, UintOptions> t, bool isRelative)
|
||||
{
|
||||
uint prevEndVal = t.endValue;
|
||||
t.endValue = t.getter();
|
||||
@ -26,37 +27,48 @@ namespace DG.Tweening.Plugins
|
||||
t.setter(t.startValue);
|
||||
}
|
||||
|
||||
public override uint ConvertToStartValue(TweenerCore<uint, uint, NoOptions> t, uint value)
|
||||
public override uint ConvertToStartValue(TweenerCore<uint, uint, UintOptions> t, uint value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public override void SetRelativeEndValue(TweenerCore<uint, uint, NoOptions> t)
|
||||
public override void SetRelativeEndValue(TweenerCore<uint, uint, UintOptions> t)
|
||||
{
|
||||
t.endValue += t.startValue;
|
||||
}
|
||||
|
||||
public override void SetChangeValue(TweenerCore<uint, uint, NoOptions> t)
|
||||
public override void SetChangeValue(TweenerCore<uint, uint, UintOptions> t)
|
||||
{
|
||||
t.changeValue = t.endValue - t.startValue;
|
||||
t.plugOptions.isNegativeChangeValue = t.endValue < t.startValue;
|
||||
t.changeValue = t.plugOptions.isNegativeChangeValue ? t.startValue - t.endValue : t.endValue - t.startValue;
|
||||
// t.changeValue = t.endValue - t.startValue;
|
||||
}
|
||||
|
||||
public override float GetSpeedBasedDuration(NoOptions options, float unitsXSecond, uint changeValue)
|
||||
public override float GetSpeedBasedDuration(UintOptions options, float unitsXSecond, uint changeValue)
|
||||
{
|
||||
float res = changeValue / unitsXSecond;
|
||||
if (res < 0) res = -res;
|
||||
return res;
|
||||
}
|
||||
|
||||
public override void EvaluateAndApply(NoOptions options, Tween t, bool isRelative, DOGetter<uint> getter, DOSetter<uint> setter, float elapsed, uint startValue, uint changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice)
|
||||
public override void EvaluateAndApply(UintOptions options, Tween t, bool isRelative, DOGetter<uint> getter, DOSetter<uint> setter, float elapsed, uint startValue, uint changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice)
|
||||
{
|
||||
if (t.loopType == LoopType.Incremental) startValue += (uint)(changeValue * (t.isComplete ? t.completedLoops - 1 : t.completedLoops));
|
||||
uint v;
|
||||
if (t.loopType == LoopType.Incremental) {
|
||||
v = (uint)(changeValue * (t.isComplete ? t.completedLoops - 1 : t.completedLoops));
|
||||
if (options.isNegativeChangeValue) startValue -= v;
|
||||
else startValue += v;
|
||||
}
|
||||
if (t.isSequenced && t.sequenceParent.loopType == LoopType.Incremental) {
|
||||
startValue += (uint)(changeValue * (t.loopType == LoopType.Incremental ? t.loops : 1)
|
||||
v = (uint)(changeValue * (t.loopType == LoopType.Incremental ? t.loops : 1)
|
||||
* (t.sequenceParent.isComplete ? t.sequenceParent.completedLoops - 1 : t.sequenceParent.completedLoops));
|
||||
if (options.isNegativeChangeValue) startValue -= v;
|
||||
else startValue += v;
|
||||
}
|
||||
|
||||
setter((uint)Math.Round(startValue + changeValue * EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod)));
|
||||
v = (uint)Math.Round(changeValue * EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod));
|
||||
if (options.isNegativeChangeValue) setter(startValue - v);
|
||||
else setter(startValue + v);
|
||||
}
|
||||
}
|
||||
}
|
||||
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