mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2025-12-21 01:36:05 +08:00
Period successfully added to Flash eases
This commit is contained in:
parent
9732b490aa
commit
2af024f03d
@ -2040,16 +2040,22 @@
|
|||||||
<summary>Sets the ease of the tween.
|
<summary>Sets the ease of the tween.
|
||||||
<para>If applied to Sequences eases the whole sequence animation</para></summary>
|
<para>If applied to Sequences eases the whole sequence animation</para></summary>
|
||||||
<param name="overshoot">
|
<param name="overshoot">
|
||||||
Eventual overshoot to use with Back ease (default is 1.70158).
|
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.
|
<para>In case of Flash ease it sets the total number of flashes that will happen.
|
||||||
Using an even number will end the tween on the starting value, while an odd one will end on the end value.</para>
|
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>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,DG.Tweening.Ease,System.Single,System.Single)">
|
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,DG.Tweening.Ease,System.Single,System.Single)">
|
||||||
<summary>Sets the ease of the tween.
|
<summary>Sets the ease of the tween.
|
||||||
<para>If applied to Sequences eases the whole sequence animation</para></summary>
|
<para>If applied to Sequences eases the whole sequence animation</para></summary>
|
||||||
<param name="amplitude">Eventual amplitude to use with Elastic easeType (default is 1.70158)</param>
|
<param name="amplitude">Eventual amplitude to use with Elastic easeType or overshoot to use with Flash easeType (default is 1.70158).
|
||||||
<param name="period">Eventual period to use with Elastic easeType (default is 0)</param>
|
<para>In case of Flash ease it 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).
|
||||||
|
<para>In case of Flash ease it indicates the power in time of the ease, and must be between -1 and 1.
|
||||||
|
0 is balanced, 1 weakens the ease with time, -1 starts the ease weakened and gives it power towards the end.</para>
|
||||||
|
</param>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,UnityEngine.AnimationCurve)">
|
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,UnityEngine.AnimationCurve)">
|
||||||
<summary>Sets the ease of the tween using an AnimationCurve.
|
<summary>Sets the ease of the tween using an AnimationCurve.
|
||||||
|
|||||||
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.
@ -2040,16 +2040,22 @@
|
|||||||
<summary>Sets the ease of the tween.
|
<summary>Sets the ease of the tween.
|
||||||
<para>If applied to Sequences eases the whole sequence animation</para></summary>
|
<para>If applied to Sequences eases the whole sequence animation</para></summary>
|
||||||
<param name="overshoot">
|
<param name="overshoot">
|
||||||
Eventual overshoot to use with Back ease (default is 1.70158).
|
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.
|
<para>In case of Flash ease it sets the total number of flashes that will happen.
|
||||||
Using an even number will end the tween on the starting value, while an odd one will end on the end value.</para>
|
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>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,DG.Tweening.Ease,System.Single,System.Single)">
|
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,DG.Tweening.Ease,System.Single,System.Single)">
|
||||||
<summary>Sets the ease of the tween.
|
<summary>Sets the ease of the tween.
|
||||||
<para>If applied to Sequences eases the whole sequence animation</para></summary>
|
<para>If applied to Sequences eases the whole sequence animation</para></summary>
|
||||||
<param name="amplitude">Eventual amplitude to use with Elastic easeType (default is 1.70158)</param>
|
<param name="amplitude">Eventual amplitude to use with Elastic easeType or overshoot to use with Flash easeType (default is 1.70158).
|
||||||
<param name="period">Eventual period to use with Elastic easeType (default is 0)</param>
|
<para>In case of Flash ease it 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).
|
||||||
|
<para>In case of Flash ease it indicates the power in time of the ease, and must be between -1 and 1.
|
||||||
|
0 is balanced, 1 weakens the ease with time, -1 starts the ease weakened and gives it power towards the end.</para>
|
||||||
|
</param>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,UnityEngine.AnimationCurve)">
|
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,UnityEngine.AnimationCurve)">
|
||||||
<summary>Sets the ease of the tween using an AnimationCurve.
|
<summary>Sets the ease of the tween using an AnimationCurve.
|
||||||
|
|||||||
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.
@ -2040,16 +2040,22 @@
|
|||||||
<summary>Sets the ease of the tween.
|
<summary>Sets the ease of the tween.
|
||||||
<para>If applied to Sequences eases the whole sequence animation</para></summary>
|
<para>If applied to Sequences eases the whole sequence animation</para></summary>
|
||||||
<param name="overshoot">
|
<param name="overshoot">
|
||||||
Eventual overshoot to use with Back ease (default is 1.70158).
|
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.
|
<para>In case of Flash ease it sets the total number of flashes that will happen.
|
||||||
Using an even number will end the tween on the starting value, while an odd one will end on the end value.</para>
|
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>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,DG.Tweening.Ease,System.Single,System.Single)">
|
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,DG.Tweening.Ease,System.Single,System.Single)">
|
||||||
<summary>Sets the ease of the tween.
|
<summary>Sets the ease of the tween.
|
||||||
<para>If applied to Sequences eases the whole sequence animation</para></summary>
|
<para>If applied to Sequences eases the whole sequence animation</para></summary>
|
||||||
<param name="amplitude">Eventual amplitude to use with Elastic easeType (default is 1.70158)</param>
|
<param name="amplitude">Eventual amplitude to use with Elastic easeType or overshoot to use with Flash easeType (default is 1.70158).
|
||||||
<param name="period">Eventual period to use with Elastic easeType (default is 0)</param>
|
<para>In case of Flash ease it 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).
|
||||||
|
<para>In case of Flash ease it indicates the power in time of the ease, and must be between -1 and 1.
|
||||||
|
0 is balanced, 1 weakens the ease with time, -1 starts the ease weakened and gives it power towards the end.</para>
|
||||||
|
</param>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,UnityEngine.AnimationCurve)">
|
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,UnityEngine.AnimationCurve)">
|
||||||
<summary>Sets the ease of the tween using an AnimationCurve.
|
<summary>Sets the ease of the tween using an AnimationCurve.
|
||||||
|
|||||||
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.
@ -10,6 +10,8 @@ public class EaseCurves : BrainBase
|
|||||||
public AnimationCurve easeCurve;
|
public AnimationCurve easeCurve;
|
||||||
public float tweenDuration = 1;
|
public float tweenDuration = 1;
|
||||||
public int txDistance = 2;
|
public int txDistance = 2;
|
||||||
|
public float easeFlashOvershoot = 16;
|
||||||
|
public float easeFlashPeriod = 1;
|
||||||
|
|
||||||
int txH, txW;
|
int txH, txW;
|
||||||
int txBorder, easeH;
|
int txBorder, easeH;
|
||||||
@ -75,10 +77,10 @@ public class EaseCurves : BrainBase
|
|||||||
img.GetComponentInChildren<Text>().text = easeType.ToString();
|
img.GetComponentInChildren<Text>().text = easeType.ToString();
|
||||||
if (easeType == Ease.INTERNAL_Custom) tween.SetEase(easeCurve);
|
if (easeType == Ease.INTERNAL_Custom) tween.SetEase(easeCurve);
|
||||||
else{
|
else{
|
||||||
float overshootOrAmplitude = easeType.ToString().IndexOf("Flash") == -1
|
bool isFlashEase = easeType.ToString().IndexOf("Flash") != -1;
|
||||||
? DOTween.defaultEaseOvershootOrAmplitude
|
float overshootOrAmplitude = isFlashEase ? easeFlashOvershoot : DOTween.defaultEaseOvershootOrAmplitude;
|
||||||
: 16;
|
float period = isFlashEase ? easeFlashPeriod : DOTween.defaultEasePeriod;
|
||||||
tween.SetEase(easeType, overshootOrAmplitude);
|
tween.SetEase(easeType, overshootOrAmplitude, period);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@ -10,14 +10,15 @@ public class EaseX : MonoBehaviour
|
|||||||
[Header("Tween Settings")]
|
[Header("Tween Settings")]
|
||||||
public float duration = 2;
|
public float duration = 2;
|
||||||
public Ease ease;
|
public Ease ease;
|
||||||
public float overshootOrAmplitude = 10;
|
public float overshootOrAmplitude = 16;
|
||||||
|
public float period = 1;
|
||||||
|
|
||||||
public void Play()
|
public void Play()
|
||||||
{
|
{
|
||||||
DOTween.RewindAll();
|
DOTween.RewindAll();
|
||||||
DOTween.KillAll();
|
DOTween.KillAll();
|
||||||
|
|
||||||
imgFlash.DOColor(flashColor, duration).SetEase(ease, overshootOrAmplitude);
|
imgFlash.DOColor(flashColor, duration).SetEase(ease, overshootOrAmplitude, period);
|
||||||
imgSmoothFlash.DOColor(flashColor, duration).SetEase(ease, overshootOrAmplitude);
|
imgSmoothFlash.DOColor(flashColor, duration).SetEase(ease, overshootOrAmplitude - 1, period);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 19 KiB |
@ -61,10 +61,6 @@ namespace DG.Tweening.Core.Easing
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static float Evaluate(Ease easeType, EaseFunction customEase, float time, float duration, float overshootOrAmplitude, float period)
|
public static float Evaluate(Ease easeType, EaseFunction customEase, float time, float duration, float overshootOrAmplitude, float period)
|
||||||
{
|
{
|
||||||
int stepIndex;
|
|
||||||
float stepDuration;
|
|
||||||
int dir;
|
|
||||||
|
|
||||||
switch (easeType) {
|
switch (easeType) {
|
||||||
case Ease.Linear:
|
case Ease.Linear:
|
||||||
return time / duration;
|
return time / duration;
|
||||||
@ -171,79 +167,13 @@ namespace DG.Tweening.Core.Easing
|
|||||||
|
|
||||||
// Extra custom eases ////////////////////////////////////////////////////
|
// Extra custom eases ////////////////////////////////////////////////////
|
||||||
case Ease.Flash:
|
case Ease.Flash:
|
||||||
// stepIndex = Mathf.CeilToInt((time / duration) * overshootOrAmplitude); // 1 to overshootOrAmplitude
|
return Flash.Ease(time, duration, overshootOrAmplitude, period);
|
||||||
// stepDuration = duration / overshootOrAmplitude;
|
|
||||||
// time -= stepDuration * (stepIndex - 1);
|
|
||||||
// dir = (stepIndex % 2 != 0) ? 1 : - 1;
|
|
||||||
// if (dir < 0) time -= stepDuration;
|
|
||||||
// float res = (time * dir) / stepDuration;
|
|
||||||
// if (period > 0) {
|
|
||||||
// float easedRes = (res * (overshootOrAmplitude - stepIndex)) / overshootOrAmplitude;
|
|
||||||
// float diff = easedRes - res;
|
|
||||||
// diff = diff * period;
|
|
||||||
// return res + diff;
|
|
||||||
// }
|
|
||||||
// if (period < 0) {
|
|
||||||
// period = -period;
|
|
||||||
// float easedRes = (res * stepIndex) / overshootOrAmplitude;
|
|
||||||
// float diff = easedRes - res;
|
|
||||||
// diff = diff * period;
|
|
||||||
// return res + diff;
|
|
||||||
// }
|
|
||||||
// return res;
|
|
||||||
|
|
||||||
float final = 0;
|
|
||||||
stepIndex = Mathf.CeilToInt((time / duration) * overshootOrAmplitude); // 1 to overshootOrAmplitude
|
|
||||||
stepDuration = duration / overshootOrAmplitude;
|
|
||||||
time -= stepDuration * (stepIndex - 1);
|
|
||||||
dir = (stepIndex % 2 != 0) ? 1 : - 1;
|
|
||||||
if (dir < 0) time -= stepDuration;
|
|
||||||
float res = (time * dir) / stepDuration;
|
|
||||||
float easedRes = 0;
|
|
||||||
if (period > 0) {
|
|
||||||
final = overshootOrAmplitude - (float)Math.Truncate(overshootOrAmplitude);
|
|
||||||
if ((float)Math.Truncate(overshootOrAmplitude) % 2 > 0) final = 1 - final;
|
|
||||||
final = (final * stepIndex) / overshootOrAmplitude;
|
|
||||||
easedRes = (res * (overshootOrAmplitude - stepIndex)) / overshootOrAmplitude;
|
|
||||||
} else if (period < 0) {
|
|
||||||
period = -period;
|
|
||||||
easedRes = (res * stepIndex) / overshootOrAmplitude;
|
|
||||||
}
|
|
||||||
float diff = easedRes - res;
|
|
||||||
res += (diff * period) + final;
|
|
||||||
if (res > 1) res = 1;
|
|
||||||
return res;
|
|
||||||
case Ease.InFlash:
|
case Ease.InFlash:
|
||||||
stepDuration = duration / overshootOrAmplitude;
|
return Flash.EaseIn(time, duration, overshootOrAmplitude, period);
|
||||||
dir = 1;
|
|
||||||
while (time > stepDuration) {
|
|
||||||
time -= stepDuration;
|
|
||||||
dir = -dir;
|
|
||||||
}
|
|
||||||
if (dir < 0) time -= stepDuration;
|
|
||||||
time = time * dir;
|
|
||||||
return (time /= stepDuration) * time;
|
|
||||||
case Ease.OutFlash:
|
case Ease.OutFlash:
|
||||||
stepDuration = duration / overshootOrAmplitude;
|
return Flash.EaseOut(time, duration, overshootOrAmplitude, period);
|
||||||
dir = 1;
|
|
||||||
while (time > stepDuration) {
|
|
||||||
time -= stepDuration;
|
|
||||||
dir = -dir;
|
|
||||||
}
|
|
||||||
if (dir < 0) time -= stepDuration;
|
|
||||||
time = time * dir;
|
|
||||||
return -(time /= stepDuration) * (time - 2);
|
|
||||||
case Ease.InOutFlash:
|
case Ease.InOutFlash:
|
||||||
stepDuration = duration / overshootOrAmplitude;
|
return Flash.EaseInOut(time, duration, overshootOrAmplitude, period);
|
||||||
dir = 1;
|
|
||||||
while (time > stepDuration) {
|
|
||||||
time -= stepDuration;
|
|
||||||
dir = -dir;
|
|
||||||
}
|
|
||||||
if (dir < 0) time -= stepDuration;
|
|
||||||
time = time * dir;
|
|
||||||
if ((time /= stepDuration * 0.5f) < 1) return 0.5f * time * time;
|
|
||||||
return -0.5f * ((--time) * (time - 2) - 1);
|
|
||||||
|
|
||||||
// Default
|
// Default
|
||||||
default:
|
default:
|
||||||
@ -254,9 +184,6 @@ namespace DG.Tweening.Core.Easing
|
|||||||
|
|
||||||
public static EaseFunction ToEaseFunction(Ease ease)
|
public static EaseFunction ToEaseFunction(Ease ease)
|
||||||
{
|
{
|
||||||
float durationStep;
|
|
||||||
int dir;
|
|
||||||
|
|
||||||
switch (ease) {
|
switch (ease) {
|
||||||
case Ease.Linear:
|
case Ease.Linear:
|
||||||
return (float time, float duration, float overshootOrAmplitude, float period) =>
|
return (float time, float duration, float overshootOrAmplitude, float period) =>
|
||||||
@ -400,53 +327,17 @@ namespace DG.Tweening.Core.Easing
|
|||||||
|
|
||||||
// Extra custom eases ////////////////////////////////////////////////////
|
// Extra custom eases ////////////////////////////////////////////////////
|
||||||
case Ease.Flash:
|
case Ease.Flash:
|
||||||
return (float time, float duration, float overshootOrAmplitude, float period) => {
|
return (float time, float duration, float overshootOrAmplitude, float period) =>
|
||||||
durationStep = duration / overshootOrAmplitude;
|
Flash.Ease(time, duration, overshootOrAmplitude, period);
|
||||||
dir = 1;
|
|
||||||
while (time > durationStep) {
|
|
||||||
time -= durationStep;
|
|
||||||
dir = -dir;
|
|
||||||
}
|
|
||||||
if (dir < 0) time -= durationStep;
|
|
||||||
return (time * dir) / durationStep;
|
|
||||||
};
|
|
||||||
case Ease.InFlash:
|
case Ease.InFlash:
|
||||||
return (float time, float duration, float overshootOrAmplitude, float period) => {
|
return (float time, float duration, float overshootOrAmplitude, float period) =>
|
||||||
durationStep = duration / overshootOrAmplitude;
|
Flash.EaseIn(time, duration, overshootOrAmplitude, period);
|
||||||
dir = 1;
|
|
||||||
while (time > durationStep) {
|
|
||||||
time -= durationStep;
|
|
||||||
dir = -dir;
|
|
||||||
}
|
|
||||||
if (dir < 0) time -= durationStep;
|
|
||||||
time = time * dir;
|
|
||||||
return (time /= durationStep) * time;
|
|
||||||
};
|
|
||||||
case Ease.OutFlash:
|
case Ease.OutFlash:
|
||||||
return (float time, float duration, float overshootOrAmplitude, float period) => {
|
return (float time, float duration, float overshootOrAmplitude, float period) =>
|
||||||
durationStep = duration / overshootOrAmplitude;
|
Flash.EaseOut(time, duration, overshootOrAmplitude, period);
|
||||||
dir = 1;
|
|
||||||
while (time > durationStep) {
|
|
||||||
time -= durationStep;
|
|
||||||
dir = -dir;
|
|
||||||
}
|
|
||||||
if (dir < 0) time -= durationStep;
|
|
||||||
time = time * dir;
|
|
||||||
return -(time /= durationStep) * (time - 2);
|
|
||||||
};
|
|
||||||
case Ease.InOutFlash:
|
case Ease.InOutFlash:
|
||||||
return (float time, float duration, float overshootOrAmplitude, float period) => {
|
return (float time, float duration, float overshootOrAmplitude, float period) =>
|
||||||
durationStep = duration / overshootOrAmplitude;
|
Flash.EaseInOut(time, duration, overshootOrAmplitude, period);
|
||||||
dir = 1;
|
|
||||||
while (time > durationStep) {
|
|
||||||
time -= durationStep;
|
|
||||||
dir = -dir;
|
|
||||||
}
|
|
||||||
if (dir < 0) time -= durationStep;
|
|
||||||
time = time * dir;
|
|
||||||
if ((time /= durationStep * 0.5f) < 1) return 0.5f * time * time;
|
|
||||||
return -0.5f * ((--time) * (time - 2) - 1);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Default
|
// Default
|
||||||
default:
|
default:
|
||||||
|
|||||||
83
_DOTween.Assembly/DOTween/Core/Easing/Flash.cs
Normal file
83
_DOTween.Assembly/DOTween/Core/Easing/Flash.cs
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
// Author: Daniele Giardini - http://www.demigiant.com
|
||||||
|
// Created: 2015/10/31 15:59
|
||||||
|
// License Copyright (c) Daniele Giardini
|
||||||
|
// This work is subject to the terms at http://dotween.demigiant.com/license.php
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
#pragma warning disable 1591
|
||||||
|
namespace DG.Tweening.Core.Easing
|
||||||
|
{
|
||||||
|
public static class Flash
|
||||||
|
{
|
||||||
|
public static float Ease(float time, float duration, float overshootOrAmplitude, float period)
|
||||||
|
{
|
||||||
|
int stepIndex = Mathf.CeilToInt((time / duration) * overshootOrAmplitude); // 1 to overshootOrAmplitude
|
||||||
|
float stepDuration = duration / overshootOrAmplitude;
|
||||||
|
time -= stepDuration * (stepIndex - 1);
|
||||||
|
float dir = (stepIndex % 2 != 0) ? 1 : -1;
|
||||||
|
if (dir < 0) time -= stepDuration;
|
||||||
|
float res = (time * dir) / stepDuration;
|
||||||
|
return WeightedEase(overshootOrAmplitude, period, stepIndex, stepDuration, dir, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float EaseIn(float time, float duration, float overshootOrAmplitude, float period)
|
||||||
|
{
|
||||||
|
int stepIndex = Mathf.CeilToInt((time / duration) * overshootOrAmplitude); // 1 to overshootOrAmplitude
|
||||||
|
float stepDuration = duration / overshootOrAmplitude;
|
||||||
|
time -= stepDuration * (stepIndex - 1);
|
||||||
|
float dir = (stepIndex % 2 != 0) ? 1 : -1;
|
||||||
|
if (dir < 0) time -= stepDuration;
|
||||||
|
time = time * dir;
|
||||||
|
float res = (time /= stepDuration) * time;
|
||||||
|
return WeightedEase(overshootOrAmplitude, period, stepIndex, stepDuration, dir, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float EaseOut(float time, float duration, float overshootOrAmplitude, float period)
|
||||||
|
{
|
||||||
|
int stepIndex = Mathf.CeilToInt((time / duration) * overshootOrAmplitude); // 1 to overshootOrAmplitude
|
||||||
|
float stepDuration = duration / overshootOrAmplitude;
|
||||||
|
time -= stepDuration * (stepIndex - 1);
|
||||||
|
float dir = (stepIndex % 2 != 0) ? 1 : -1;
|
||||||
|
if (dir < 0) time -= stepDuration;
|
||||||
|
time = time * dir;
|
||||||
|
float res = -(time /= stepDuration) * (time - 2);
|
||||||
|
return WeightedEase(overshootOrAmplitude, period, stepIndex, stepDuration, dir, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float EaseInOut(float time, float duration, float overshootOrAmplitude, float period)
|
||||||
|
{
|
||||||
|
int stepIndex = Mathf.CeilToInt((time / duration) * overshootOrAmplitude); // 1 to overshootOrAmplitude
|
||||||
|
float stepDuration = duration / overshootOrAmplitude;
|
||||||
|
time -= stepDuration * (stepIndex - 1);
|
||||||
|
float dir = (stepIndex % 2 != 0) ? 1 : -1;
|
||||||
|
if (dir < 0) time -= stepDuration;
|
||||||
|
time = time * dir;
|
||||||
|
float res = (time /= stepDuration * 0.5f) < 1
|
||||||
|
? 0.5f * time * time
|
||||||
|
: -0.5f * ((--time) * (time - 2) - 1);
|
||||||
|
return WeightedEase(overshootOrAmplitude, period, stepIndex, stepDuration, dir, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
static float WeightedEase(float overshootOrAmplitude, float period, int stepIndex, float stepDuration, float dir, float res)
|
||||||
|
{
|
||||||
|
float easedRes = 0;
|
||||||
|
float finalDecimals = 0;
|
||||||
|
if (period > 0) {
|
||||||
|
float finalTruncated = (float)Math.Truncate(overshootOrAmplitude);
|
||||||
|
finalDecimals = overshootOrAmplitude - finalTruncated;
|
||||||
|
if (finalTruncated % 2 > 0) finalDecimals = 1 - finalDecimals;
|
||||||
|
finalDecimals = (finalDecimals * stepIndex) / overshootOrAmplitude;
|
||||||
|
easedRes = (res * (overshootOrAmplitude - stepIndex)) / overshootOrAmplitude;
|
||||||
|
} else if (period < 0) {
|
||||||
|
period = -period;
|
||||||
|
easedRes = (res * stepIndex) / overshootOrAmplitude;
|
||||||
|
}
|
||||||
|
float diff = easedRes - res;
|
||||||
|
res += (diff * period) + finalDecimals;
|
||||||
|
if (res > 1) res = 1;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -65,6 +65,7 @@
|
|||||||
<Compile Include="Core\Easing\Bounce.cs" />
|
<Compile Include="Core\Easing\Bounce.cs" />
|
||||||
<Compile Include="Core\Easing\EaseManager.cs" />
|
<Compile Include="Core\Easing\EaseManager.cs" />
|
||||||
<Compile Include="Core\Easing\EaseCurve.cs" />
|
<Compile Include="Core\Easing\EaseCurve.cs" />
|
||||||
|
<Compile Include="Core\Easing\Flash.cs" />
|
||||||
<Compile Include="Core\Enums\FilterType.cs" />
|
<Compile Include="Core\Enums\FilterType.cs" />
|
||||||
<Compile Include="Core\Enums\OperationType.cs" />
|
<Compile Include="Core\Enums\OperationType.cs" />
|
||||||
<Compile Include="Core\Enums\SpecialStartupMode.cs" />
|
<Compile Include="Core\Enums\SpecialStartupMode.cs" />
|
||||||
|
|||||||
@ -127,9 +127,9 @@ namespace DG.Tweening
|
|||||||
/// <summary>Sets the ease of the tween.
|
/// <summary>Sets the ease of the tween.
|
||||||
/// <para>If applied to Sequences eases the whole sequence animation</para></summary>
|
/// <para>If applied to Sequences eases the whole sequence animation</para></summary>
|
||||||
/// <param name="overshoot">
|
/// <param name="overshoot">
|
||||||
/// Eventual overshoot to use with Back ease (default is 1.70158).
|
/// 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.
|
/// <para>In case of Flash ease it sets the total number of flashes that will happen.
|
||||||
/// Using an even number will end the tween on the starting value, while an odd one will end on the end value.</para>
|
/// 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>
|
||||||
public static T SetEase<T>(this T t, Ease ease, float overshoot) where T : Tween
|
public static T SetEase<T>(this T t, Ease ease, float overshoot) where T : Tween
|
||||||
{
|
{
|
||||||
@ -142,8 +142,14 @@ namespace DG.Tweening
|
|||||||
}
|
}
|
||||||
/// <summary>Sets the ease of the tween.
|
/// <summary>Sets the ease of the tween.
|
||||||
/// <para>If applied to Sequences eases the whole sequence animation</para></summary>
|
/// <para>If applied to Sequences eases the whole sequence animation</para></summary>
|
||||||
/// <param name="amplitude">Eventual amplitude to use with Elastic easeType (default is 1.70158)</param>
|
/// <param name="amplitude">Eventual amplitude to use with Elastic easeType or overshoot to use with Flash easeType (default is 1.70158).
|
||||||
/// <param name="period">Eventual period to use with Elastic easeType (default is 0)</param>
|
/// <para>In case of Flash ease it 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).
|
||||||
|
/// <para>In case of Flash ease it indicates the power in time of the ease, and must be between -1 and 1.
|
||||||
|
/// 0 is balanced, 1 weakens the ease with time, -1 starts the ease weakened and gives it power towards the end.</para>
|
||||||
|
/// </param>
|
||||||
public static T SetEase<T>(this T t, Ease ease, float amplitude, float period) where T : Tween
|
public static T SetEase<T>(this T t, Ease ease, float amplitude, float period) where T : Tween
|
||||||
{
|
{
|
||||||
if (t == null || !t.active) return t;
|
if (t == null || !t.active) return t;
|
||||||
|
|||||||
@ -2040,16 +2040,22 @@
|
|||||||
<summary>Sets the ease of the tween.
|
<summary>Sets the ease of the tween.
|
||||||
<para>If applied to Sequences eases the whole sequence animation</para></summary>
|
<para>If applied to Sequences eases the whole sequence animation</para></summary>
|
||||||
<param name="overshoot">
|
<param name="overshoot">
|
||||||
Eventual overshoot to use with Back ease (default is 1.70158).
|
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.
|
<para>In case of Flash ease it sets the total number of flashes that will happen.
|
||||||
Using an even number will end the tween on the starting value, while an odd one will end on the end value.</para>
|
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>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,DG.Tweening.Ease,System.Single,System.Single)">
|
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,DG.Tweening.Ease,System.Single,System.Single)">
|
||||||
<summary>Sets the ease of the tween.
|
<summary>Sets the ease of the tween.
|
||||||
<para>If applied to Sequences eases the whole sequence animation</para></summary>
|
<para>If applied to Sequences eases the whole sequence animation</para></summary>
|
||||||
<param name="amplitude">Eventual amplitude to use with Elastic easeType (default is 1.70158)</param>
|
<param name="amplitude">Eventual amplitude to use with Elastic easeType or overshoot to use with Flash easeType (default is 1.70158).
|
||||||
<param name="period">Eventual period to use with Elastic easeType (default is 0)</param>
|
<para>In case of Flash ease it 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).
|
||||||
|
<para>In case of Flash ease it indicates the power in time of the ease, and must be between -1 and 1.
|
||||||
|
0 is balanced, 1 weakens the ease with time, -1 starts the ease weakened and gives it power towards the end.</para>
|
||||||
|
</param>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,UnityEngine.AnimationCurve)">
|
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,UnityEngine.AnimationCurve)">
|
||||||
<summary>Sets the ease of the tween using an AnimationCurve.
|
<summary>Sets the ease of the tween using an AnimationCurve.
|
||||||
|
|||||||
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