mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2025-12-20 17:26:03 +08:00
Added Flash eases
This commit is contained in:
parent
2c22181c73
commit
b58e6d062a
@ -2039,7 +2039,11 @@
|
||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,DG.Tweening.Ease,System.Single)">
|
||||
<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 ease (default is 1.70158)</param>
|
||||
<param name="overshoot">
|
||||
Eventual overshoot to use with Back ease (default is 1.70158).
|
||||
<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>
|
||||
</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,DG.Tweening.Ease,System.Single,System.Single)">
|
||||
<summary>Sets the ease of the tween.
|
||||
|
||||
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.
@ -2039,7 +2039,11 @@
|
||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,DG.Tweening.Ease,System.Single)">
|
||||
<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 ease (default is 1.70158)</param>
|
||||
<param name="overshoot">
|
||||
Eventual overshoot to use with Back ease (default is 1.70158).
|
||||
<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>
|
||||
</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,DG.Tweening.Ease,System.Single,System.Single)">
|
||||
<summary>Sets the ease of the tween.
|
||||
|
||||
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.
@ -2039,7 +2039,11 @@
|
||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,DG.Tweening.Ease,System.Single)">
|
||||
<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 ease (default is 1.70158)</param>
|
||||
<param name="overshoot">
|
||||
Eventual overshoot to use with Back ease (default is 1.70158).
|
||||
<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>
|
||||
</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,DG.Tweening.Ease,System.Single,System.Single)">
|
||||
<summary>Sets the ease of the tween.
|
||||
|
||||
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.
@ -74,7 +74,12 @@ public class EaseCurves : BrainBase
|
||||
} else {
|
||||
img.GetComponentInChildren<Text>().text = easeType.ToString();
|
||||
if (easeType == Ease.INTERNAL_Custom) tween.SetEase(easeCurve);
|
||||
else tween.SetEase(easeType);
|
||||
else{
|
||||
float overshootOrAmplitude = easeType.ToString().IndexOf("Flash") == -1
|
||||
? DOTween.defaultEaseOvershootOrAmplitude
|
||||
: 16;
|
||||
tween.SetEase(easeType, overshootOrAmplitude);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Disable original image
|
||||
|
||||
Binary file not shown.
23
UnityTests.Unity5/Assets/_Tests/EaseX.cs
Normal file
23
UnityTests.Unity5/Assets/_Tests/EaseX.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections;
|
||||
using DG.Tweening;
|
||||
|
||||
public class EaseX : MonoBehaviour
|
||||
{
|
||||
public Image imgFlash, imgSmoothFlash;
|
||||
public Color flashColor;
|
||||
[Header("Tween Settings")]
|
||||
public float duration = 2;
|
||||
public Ease ease;
|
||||
public float overshootOrAmplitude = 10;
|
||||
|
||||
public void Play()
|
||||
{
|
||||
DOTween.RewindAll();
|
||||
DOTween.KillAll();
|
||||
|
||||
imgFlash.DOColor(flashColor, duration).SetEase(ease, overshootOrAmplitude);
|
||||
imgSmoothFlash.DOColor(flashColor, duration).SetEase(ease, overshootOrAmplitude);
|
||||
}
|
||||
}
|
||||
12
UnityTests.Unity5/Assets/_Tests/EaseX.cs.meta
Normal file
12
UnityTests.Unity5/Assets/_Tests/EaseX.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0bb9dc09d685d8d4098a093a5c9844a2
|
||||
timeCreated: 1446226102
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
UnityTests.Unity5/Assets/_Tests/EaseX.unity
Normal file
BIN
UnityTests.Unity5/Assets/_Tests/EaseX.unity
Normal file
Binary file not shown.
8
UnityTests.Unity5/Assets/_Tests/EaseX.unity.meta
Normal file
8
UnityTests.Unity5/Assets/_Tests/EaseX.unity.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa19e668bdb591b43ac79271427d506f
|
||||
timeCreated: 1446226089
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -20,6 +20,9 @@ TextureImporter:
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 0
|
||||
cubemapConvolution: 0
|
||||
cubemapConvolutionSteps: 8
|
||||
cubemapConvolutionExponent: 1.5
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -3
|
||||
maxTextureSize: 128
|
||||
@ -30,7 +33,9 @@ TextureImporter:
|
||||
wrapMode: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
rGBM: 0
|
||||
compressionQuality: 50
|
||||
allowsAlphaSplitting: 0
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
@ -45,3 +50,5 @@ TextureImporter:
|
||||
sprites: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 8.3 KiB |
@ -0,0 +1,56 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0fbf5b9286dfec4ebb8c58cbf73369e
|
||||
timeCreated: 1446234642
|
||||
licenseType: Free
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
serializedVersion: 2
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
linearTexture: 0
|
||||
correctGamma: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: .25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 0
|
||||
cubemapConvolution: 0
|
||||
cubemapConvolutionSteps: 8
|
||||
cubemapConvolutionExponent: 1.5
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -3
|
||||
maxTextureSize: 256
|
||||
textureSettings:
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -1
|
||||
wrapMode: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
rGBM: 0
|
||||
compressionQuality: 50
|
||||
allowsAlphaSplitting: 0
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: .5, y: .5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaIsTransparency: 1
|
||||
textureType: 8
|
||||
buildTargetSettings: []
|
||||
spriteSheet:
|
||||
sprites: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
@ -0,0 +1,56 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 159f24a8249bb244a91671b58f1d7441
|
||||
timeCreated: 1446234463
|
||||
licenseType: Free
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
serializedVersion: 2
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
linearTexture: 0
|
||||
correctGamma: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: .25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 0
|
||||
cubemapConvolution: 0
|
||||
cubemapConvolutionSteps: 8
|
||||
cubemapConvolutionExponent: 1.5
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -3
|
||||
maxTextureSize: 1024
|
||||
textureSettings:
|
||||
filterMode: -1
|
||||
aniso: 16
|
||||
mipBias: -1
|
||||
wrapMode: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
rGBM: 0
|
||||
compressionQuality: 50
|
||||
allowsAlphaSplitting: 0
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: .5, y: .5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaIsTransparency: 1
|
||||
textureType: 8
|
||||
buildTargetSettings: []
|
||||
spriteSheet:
|
||||
sprites: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -5,8 +5,10 @@
|
||||
// This work is subject to the terms at http://dotween.demigiant.com/license.php
|
||||
//
|
||||
// =============================================================
|
||||
// Contains Daniele Giardini's C# port of the easing equations created
|
||||
// by Robert Penner - http://robertpenner.com/easing, see license below:
|
||||
// Contains Daniele Giardini's C# port of the easing equations created by Robert Penner
|
||||
// (all easing equations except for Flash, InFlash, OutFlash, InOutFlash,
|
||||
// which use some parts of Robert Penner's equations but were created by Daniele Giardini)
|
||||
// http://robertpenner.com/easing, see license below:
|
||||
// =============================================================
|
||||
//
|
||||
// TERMS OF USE - EASING EQUATIONS
|
||||
@ -59,6 +61,9 @@ namespace DG.Tweening.Core.Easing
|
||||
/// </summary>
|
||||
public static float Evaluate(Ease easeType, EaseFunction customEase, float time, float duration, float overshootOrAmplitude, float period)
|
||||
{
|
||||
float durationStep;
|
||||
int dir;
|
||||
|
||||
switch (easeType) {
|
||||
case Ease.Linear:
|
||||
return time / duration;
|
||||
@ -162,6 +167,50 @@ namespace DG.Tweening.Core.Easing
|
||||
case Ease.INTERNAL_Zero:
|
||||
// 0 duration tween
|
||||
return 1;
|
||||
|
||||
// Extra custom eases ////////////////////////////////////////////////////
|
||||
case Ease.Flash:
|
||||
durationStep = duration / overshootOrAmplitude;
|
||||
dir = 1;
|
||||
while (time > durationStep) {
|
||||
time -= durationStep;
|
||||
dir = -dir;
|
||||
}
|
||||
if (dir < 0) time -= durationStep;
|
||||
return (time * dir) / durationStep;
|
||||
case Ease.InFlash:
|
||||
durationStep = duration / overshootOrAmplitude;
|
||||
dir = 1;
|
||||
while (time > durationStep) {
|
||||
time -= durationStep;
|
||||
dir = -dir;
|
||||
}
|
||||
if (dir < 0) time -= durationStep;
|
||||
time = time * dir;
|
||||
return (time /= durationStep) * time;
|
||||
case Ease.OutFlash:
|
||||
durationStep = duration / overshootOrAmplitude;
|
||||
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:
|
||||
durationStep = duration / overshootOrAmplitude;
|
||||
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:
|
||||
// OutQuad
|
||||
return -(time /= duration) * (time - 2);
|
||||
@ -170,6 +219,9 @@ namespace DG.Tweening.Core.Easing
|
||||
|
||||
public static EaseFunction ToEaseFunction(Ease ease)
|
||||
{
|
||||
float durationStep;
|
||||
int dir;
|
||||
|
||||
switch (ease) {
|
||||
case Ease.Linear:
|
||||
return (float time, float duration, float overshootOrAmplitude, float period) =>
|
||||
@ -310,6 +362,58 @@ namespace DG.Tweening.Core.Easing
|
||||
case Ease.InOutBounce:
|
||||
return (float time, float duration, float overshootOrAmplitude, float period) =>
|
||||
Bounce.EaseInOut(time, duration, overshootOrAmplitude, period);
|
||||
|
||||
// Extra custom eases ////////////////////////////////////////////////////
|
||||
case Ease.Flash:
|
||||
return (float time, float duration, float overshootOrAmplitude, float period) => {
|
||||
durationStep = duration / overshootOrAmplitude;
|
||||
dir = 1;
|
||||
while (time > durationStep) {
|
||||
time -= durationStep;
|
||||
dir = -dir;
|
||||
}
|
||||
if (dir < 0) time -= durationStep;
|
||||
return (time * dir) / durationStep;
|
||||
};
|
||||
case Ease.InFlash:
|
||||
return (float time, float duration, float overshootOrAmplitude, float period) => {
|
||||
durationStep = duration / overshootOrAmplitude;
|
||||
dir = 1;
|
||||
while (time > durationStep) {
|
||||
time -= durationStep;
|
||||
dir = -dir;
|
||||
}
|
||||
if (dir < 0) time -= durationStep;
|
||||
time = time * dir;
|
||||
return (time /= durationStep) * time;
|
||||
};
|
||||
case Ease.OutFlash:
|
||||
return (float time, float duration, float overshootOrAmplitude, float period) => {
|
||||
durationStep = duration / overshootOrAmplitude;
|
||||
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:
|
||||
return (float time, float duration, float overshootOrAmplitude, float period) => {
|
||||
durationStep = duration / overshootOrAmplitude;
|
||||
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:
|
||||
// OutQuad
|
||||
return (float time, float duration, float overshootOrAmplitude, float period) => -(time /= duration) * (time - 2);
|
||||
|
||||
@ -32,7 +32,7 @@ namespace DG.Tweening
|
||||
public class DOTween
|
||||
{
|
||||
/// <summary>DOTween's version</summary>
|
||||
public static readonly string Version = "1.1.030";
|
||||
public static readonly string Version = "1.1.050";
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// Options ////////////////////////////////////
|
||||
|
||||
@ -40,6 +40,8 @@ namespace DG.Tweening
|
||||
InBounce,
|
||||
OutBounce,
|
||||
InOutBounce,
|
||||
// Extra custom eases
|
||||
Flash, InFlash, OutFlash, InOutFlash,
|
||||
/// <summary>
|
||||
/// Don't assign this! It's assigned automatically when creating 0 duration tweens
|
||||
/// </summary>
|
||||
|
||||
@ -126,7 +126,11 @@ namespace DG.Tweening
|
||||
}
|
||||
/// <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 ease (default is 1.70158)</param>
|
||||
/// <param name="overshoot">
|
||||
/// Eventual overshoot to use with Back ease (default is 1.70158).
|
||||
/// <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>
|
||||
/// </param>
|
||||
public static T SetEase<T>(this T t, Ease ease, float overshoot) where T : Tween
|
||||
{
|
||||
if (t == null || !t.active) return t;
|
||||
|
||||
@ -2039,7 +2039,11 @@
|
||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,DG.Tweening.Ease,System.Single)">
|
||||
<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 ease (default is 1.70158)</param>
|
||||
<param name="overshoot">
|
||||
Eventual overshoot to use with Back ease (default is 1.70158).
|
||||
<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>
|
||||
</param>
|
||||
</member>
|
||||
<member name="M:DG.Tweening.TweenSettingsExtensions.SetEase``1(``0,DG.Tweening.Ease,System.Single,System.Single)">
|
||||
<summary>Sets the ease of the tween.
|
||||
|
||||
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