Skip to content

Commit

Permalink
Fix for Flash ease not appearing fluid when moving slowly
Browse files Browse the repository at this point in the history
  • Loading branch information
Demigiant committed Dec 8, 2015
1 parent c3c28dd commit 85d2e96
Show file tree
Hide file tree
Showing 50 changed files with 46 additions and 22 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.
8 changes: 4 additions & 4 deletions UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.XML

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween43.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween43.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween46.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween46.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween50.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween50.dll.mdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 4 additions & 4 deletions UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.XML

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween43.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween43.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween46.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween46.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween50.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween50.dll.mdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 5 additions & 1 deletion UnityTests.Unity5/Assets/_Tests/TempTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
public class TempTests : BrainBase
{
public Transform target;
public float duration = 8;
public Ease ease;
public float amplitude = 8;
public float period = 1;

IEnumerator Start()
{
yield return new WaitForSeconds(0.5f);

target.DOMoveY(2, 5).SetRelative().SetEase(Ease.InOutFlash, 8, 1);
target.DOMoveY(2, duration).SetRelative().SetEase(ease, amplitude, period);
}
}
Binary file modified UnityTests.Unity5/Assets/_Tests/TempTests.unity
Binary file not shown.
12 changes: 12 additions & 0 deletions _DOTween.Assembly/DOTween/Core/Easing/EaseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,5 +345,17 @@ public static EaseFunction ToEaseFunction(Ease ease)
return (float time, float duration, float overshootOrAmplitude, float period) => -(time /= duration) * (time - 2);
}
}

internal static bool IsFlashEase(Ease ease)
{
switch (ease) {
case Ease.Flash:
case Ease.InFlash:
case Ease.OutFlash:
case Ease.InOutFlash:
return true;
}
return false;
}
}
}
4 changes: 4 additions & 0 deletions _DOTween.Assembly/DOTween/Core/Easing/Flash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ static float WeightedEase(float overshootOrAmplitude, float period, int stepInde
{
float easedRes = 0;
float finalDecimals = 0;
// Use previous stepIndex in case of odd ones, so that back ease is not clamped
if (dir > 0 && (int)overshootOrAmplitude % 2 == 0) stepIndex++;
else if (dir < 0 && (int)overshootOrAmplitude % 2 != 0) stepIndex++;

if (period > 0) {
float finalTruncated = (float)Math.Truncate(overshootOrAmplitude);
finalDecimals = overshootOrAmplitude - finalTruncated;
Expand Down
2 changes: 1 addition & 1 deletion _DOTween.Assembly/DOTween/DOTween.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace DG.Tweening
public class DOTween
{
/// <summary>DOTween's version</summary>
public static readonly string Version = "1.1.140";
public static readonly string Version = "1.1.145";

///////////////////////////////////////////////
// Options ////////////////////////////////////
Expand Down
12 changes: 8 additions & 4 deletions _DOTween.Assembly/DOTween/TweenSettingsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,29 +121,32 @@ public static T SetEase<T>(this T t, Ease ease) where T : Tween
if (t == null || !t.active) return t;

t.easeType = ease;
if (EaseManager.IsFlashEase(ease)) t.easeOvershootOrAmplitude = (int)t.easeOvershootOrAmplitude;

t.customEase = null;
return t;
}
/// <summary>Sets the ease of the tween.
/// <para>If applied to Sequences eases the whole sequence animation</para></summary>
/// <param name="overshoot">
/// Eventual overshoot to use with Back or Flash ease (default is 1.70158).
/// <para>In case of Flash ease it sets the total number of flashes that will happen.
/// Eventual overshoot to use with Back or Flash ease (default is 1.70158 - 1 for Flash).
/// <para>In case of Flash ease it must be an intenger and sets the total number of flashes that will happen.
/// Using an even number will complete the tween on the starting value, while an odd one will complete it on the end value.</para>
/// </param>
public static T SetEase<T>(this T t, Ease ease, float overshoot) where T : Tween
{
if (t == null || !t.active) return t;

t.easeType = ease;
if (EaseManager.IsFlashEase(ease)) overshoot = (int)overshoot;
t.easeOvershootOrAmplitude = overshoot;
t.customEase = null;
return t;
}
/// <summary>Sets the ease of the tween.
/// <para>If applied to Sequences eases the whole sequence animation</para></summary>
/// <param name="amplitude">Eventual amplitude to use with Elastic easeType or overshoot to use with Flash easeType (default is 1.70158).
/// <para>In case of Flash ease it sets the total number of flashes that will happen.
/// <param name="amplitude">Eventual amplitude to use with Elastic easeType or overshoot to use with Flash easeType (default is 1.70158 - 1 for Flash).
/// <para>In case of Flash ease it must be an integer and sets the total number of flashes that will happen.
/// Using an even number will complete the tween on the starting value, while an odd one will complete it on the end value.</para>
/// </param>
/// <param name="period">Eventual period to use with Elastic or Flash easeType (default is 0).
Expand All @@ -155,6 +158,7 @@ public static T SetEase<T>(this T t, Ease ease, float amplitude, float period) w
if (t == null || !t.active) return t;

t.easeType = ease;
if (EaseManager.IsFlashEase(ease)) amplitude = (int)amplitude;
t.easeOvershootOrAmplitude = amplitude;
t.easePeriod = period;
t.customEase = null;
Expand Down
8 changes: 4 additions & 4 deletions _DOTween.Assembly/bin/DOTween.XML

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified _DOTween.Assembly/bin/DOTween.dll
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween.dll.mdb
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween43.dll
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween43.dll.mdb
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween46.dll
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween46.dll.mdb
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween50.dll
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween50.dll.mdb
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/Editor/DOTweenEditor.dll
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/Editor/DOTweenEditor.dll.mdb
Binary file not shown.

0 comments on commit 85d2e96

Please sign in to comment.