1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-20 17:26:03 +08:00

Added DoublePlugin

This commit is contained in:
Demigiant 2015-10-09 11:07:30 +02:00
parent afa90db39e
commit 49e6a0bb55
42 changed files with 112 additions and 2 deletions

View File

@ -331,6 +331,14 @@
<para>Example usage with lambda:</para><code>x=> myProperty = x</code></param> <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> <param name="endValue">The end value to reach</param><param name="duration">The tween's duration</param>
</member> </member>
<member name="M:DG.Tweening.DOTween.To(DG.Tweening.Core.DOGetter{System.Double},DG.Tweening.Core.DOSetter{System.Double},System.Single,System.Single)">
<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>
<param name="setter">A setter for the field or property to tween
<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>
</member>
<member name="M:DG.Tweening.DOTween.To(DG.Tweening.Core.DOGetter{System.Int32},DG.Tweening.Core.DOSetter{System.Int32},System.Int32,System.Single)"> <member name="M:DG.Tweening.DOTween.To(DG.Tweening.Core.DOGetter{System.Int32},DG.Tweening.Core.DOSetter{System.Int32},System.Int32,System.Single)">
<summary>Tweens a property or field to the given value using default plugins</summary> <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. <param name="getter">A getter for the field or property to tween.

View File

@ -331,6 +331,14 @@
<para>Example usage with lambda:</para><code>x=> myProperty = x</code></param> <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> <param name="endValue">The end value to reach</param><param name="duration">The tween's duration</param>
</member> </member>
<member name="M:DG.Tweening.DOTween.To(DG.Tweening.Core.DOGetter{System.Double},DG.Tweening.Core.DOSetter{System.Double},System.Single,System.Single)">
<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>
<param name="setter">A setter for the field or property to tween
<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>
</member>
<member name="M:DG.Tweening.DOTween.To(DG.Tweening.Core.DOGetter{System.Int32},DG.Tweening.Core.DOSetter{System.Int32},System.Int32,System.Single)"> <member name="M:DG.Tweening.DOTween.To(DG.Tweening.Core.DOGetter{System.Int32},DG.Tweening.Core.DOSetter{System.Int32},System.Int32,System.Single)">
<summary>Tweens a property or field to the given value using default plugins</summary> <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. <param name="getter">A getter for the field or property to tween.

View File

@ -331,6 +331,14 @@
<para>Example usage with lambda:</para><code>x=> myProperty = x</code></param> <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> <param name="endValue">The end value to reach</param><param name="duration">The tween's duration</param>
</member> </member>
<member name="M:DG.Tweening.DOTween.To(DG.Tweening.Core.DOGetter{System.Double},DG.Tweening.Core.DOSetter{System.Double},System.Single,System.Single)">
<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>
<param name="setter">A setter for the field or property to tween
<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>
</member>
<member name="M:DG.Tweening.DOTween.To(DG.Tweening.Core.DOGetter{System.Int32},DG.Tweening.Core.DOSetter{System.Int32},System.Int32,System.Single)"> <member name="M:DG.Tweening.DOTween.To(DG.Tweening.Core.DOGetter{System.Int32},DG.Tweening.Core.DOSetter{System.Int32},System.Int32,System.Single)">
<summary>Tweens a property or field to the given value using default plugins</summary> <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. <param name="getter">A getter for the field or property to tween.

View File

@ -17,7 +17,7 @@ public class Basics : BrainBase
public GameObject specularSphere; public GameObject specularSphere;
public Transform targetToDoLookAt, targetToDoLookFrom; public Transform targetToDoLookAt, targetToDoLookFrom;
public GUITexture guiTexAlpha, guiTexColor; public GUITexture guiTexAlpha, guiTexColor;
public GUIText txtInfo, txtFloat, txtInt, txtUint, txtLong, txtUlong, txtVector2, txtVector4, txtRect, txtRectOffset, txtString0, txtString1, txtString2; public GUIText txtInfo, txtFloat, txtDouble, txtInt, txtUint, txtLong, txtUlong, txtVector2, txtVector4, txtRect, txtRectOffset, txtString0, txtString1, txtString2;
public GameObject txtBackwards; public GameObject txtBackwards;
int intId = 4; int intId = 4;
@ -27,6 +27,7 @@ public class Basics : BrainBase
int intToTween; int intToTween;
uint uintToTween; uint uintToTween;
float floatToTween; float floatToTween;
double doubleToTween;
long longToTween; long longToTween;
ulong ulongToTween; ulong ulongToTween;
Vector2 vector2toTween; Vector2 vector2toTween;
@ -97,6 +98,8 @@ public class Basics : BrainBase
// Additional tweens ////////////////////////// // Additional tweens //////////////////////////
// Float // Float
DOTween.To(()=> floatToTween, x=> floatToTween = x, 100, 1.5f).SetAs(tp).Pause(); DOTween.To(()=> floatToTween, x=> floatToTween = x, 100, 1.5f).SetAs(tp).Pause();
// Double
DOTween.To(()=> doubleToTween, x=> doubleToTween = x, 100, 1.5f).SetAs(tp).Pause();
// Int // Int
DOTween.To(()=> intToTween, x=> intToTween = x, 100, 1.5f).SetAs(tp).Pause(); DOTween.To(()=> intToTween, x=> intToTween = x, 100, 1.5f).SetAs(tp).Pause();
// Uint // Uint
@ -142,6 +145,7 @@ public class Basics : BrainBase
void LateUpdate() void LateUpdate()
{ {
txtFloat.text = "float: " + floatToTween; txtFloat.text = "float: " + floatToTween;
txtDouble.text = "double: " + doubleToTween;
txtInt.text = "int: " + intToTween; txtInt.text = "int: " + intToTween;
txtUint.text = "uint: " + uintToTween; txtUint.text = "uint: " + uintToTween;
txtLong.text = "long: " + longToTween.ToString("n"); txtLong.text = "long: " + longToTween.ToString("n");

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.0.865"; public static readonly string Version = "1.1.000";
/////////////////////////////////////////////// ///////////////////////////////////////////////
// Options //////////////////////////////////// // Options ////////////////////////////////////
@ -288,6 +288,14 @@ namespace DG.Tweening
/// <param name="setter">A setter for the field or property to tween /// <param name="setter">A setter for the field or property to tween
/// <para>Example usage with lambda:</para><code>x=> myProperty = x</code></param> /// <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> /// <param name="endValue">The end value to reach</param><param name="duration">The tween's duration</param>
public static TweenerCore<double, double, NoOptions> To(DOGetter<double> getter, DOSetter<double> setter, float endValue, float duration)
{ return ApplyTo<double, double, NoOptions>(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>
/// <param name="setter">A setter for the field or property to tween
/// <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<int> getter, DOSetter<int> setter, int endValue,float duration) public static Tweener To(DOGetter<int> getter, DOSetter<int> setter, int endValue,float duration)
{ return ApplyTo<int, int, NoOptions>(getter, setter, endValue, duration); } { return ApplyTo<int, int, NoOptions>(getter, setter, endValue, duration); }
/// <summary>Tweens a property or field to the given value using default plugins</summary> /// <summary>Tweens a property or field to the given value using default plugins</summary>

View File

@ -89,6 +89,7 @@
<Compile Include="Plugins\Color2Plugin.cs" /> <Compile Include="Plugins\Color2Plugin.cs" />
<Compile Include="Plugins\ColorWrapperPlugin.cs" /> <Compile Include="Plugins\ColorWrapperPlugin.cs" />
<Compile Include="Plugins\Core\PathCore\ControlPoint.cs" /> <Compile Include="Plugins\Core\PathCore\ControlPoint.cs" />
<Compile Include="Plugins\DoublePlugin.cs" />
<Compile Include="Plugins\LongPlugin.cs" /> <Compile Include="Plugins\LongPlugin.cs" />
<Compile Include="Plugins\Options\PathOptions.cs" /> <Compile Include="Plugins\Options\PathOptions.cs" />
<Compile Include="Plugins\Options\QuaternionOptions.cs" /> <Compile Include="Plugins\Options\QuaternionOptions.cs" />

View File

@ -38,6 +38,7 @@ namespace DG.Tweening.Plugins.Core
{ {
// Default plugins // Default plugins
static ITweenPlugin _floatPlugin; static ITweenPlugin _floatPlugin;
static ITweenPlugin _doublePlugin;
static ITweenPlugin _intPlugin; static ITweenPlugin _intPlugin;
static ITweenPlugin _uintPlugin; static ITweenPlugin _uintPlugin;
static ITweenPlugin _longPlugin; static ITweenPlugin _longPlugin;
@ -113,6 +114,9 @@ namespace DG.Tweening.Plugins.Core
} else if (t1 == typeof(ulong)) { } else if (t1 == typeof(ulong)) {
if (_ulongPlugin == null) _ulongPlugin = new UlongPlugin(); if (_ulongPlugin == null) _ulongPlugin = new UlongPlugin();
plugin = _ulongPlugin; plugin = _ulongPlugin;
} else if (t1 == typeof(double)) {
if (_doublePlugin == null) _doublePlugin = new DoublePlugin();
plugin = _doublePlugin;
} }
if (plugin != null) return plugin as ABSTweenPlugin<T1, T2, TPlugOptions>; if (plugin != null) return plugin as ABSTweenPlugin<T1, T2, TPlugOptions>;

View File

@ -0,0 +1,61 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2015/10/09 10:53
// License Copyright (c) Daniele Giardini
// This work is subject to the terms at http://dotween.demigiant.com/license.php
using System;
using DG.Tweening.Core;
using DG.Tweening.Core.Easing;
using DG.Tweening.Core.Enums;
using DG.Tweening.Plugins.Core;
using DG.Tweening.Plugins.Options;
#pragma warning disable 1591
namespace DG.Tweening.Plugins
{
public class DoublePlugin : ABSTweenPlugin<double, double, NoOptions>
{
public override void Reset(TweenerCore<double, double, NoOptions> t) { }
public override void SetFrom(TweenerCore<double, double, NoOptions> t, bool isRelative)
{
double prevEndVal = t.endValue;
t.endValue = t.getter();
t.startValue = isRelative ? t.endValue + prevEndVal : prevEndVal;
t.setter(t.startValue);
}
public override double ConvertToStartValue(TweenerCore<double, double, NoOptions> t, double value)
{
return value;
}
public override void SetRelativeEndValue(TweenerCore<double, double, NoOptions> t)
{
t.endValue += t.startValue;
}
public override void SetChangeValue(TweenerCore<double, double, NoOptions> t)
{
t.changeValue = t.endValue - t.startValue;
}
public override float GetSpeedBasedDuration(NoOptions options, float unitsXSecond, double changeValue)
{
float res = (float)changeValue / unitsXSecond;
if (res < 0) res = -res;
return res;
}
public override void EvaluateAndApply(NoOptions options, Tween t, bool isRelative, DOGetter<double> getter, DOSetter<double> setter, float elapsed, double startValue, double changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice)
{
if (t.loopType == LoopType.Incremental) startValue += changeValue * (t.isComplete ? t.completedLoops - 1 : t.completedLoops);
if (t.isSequenced && t.sequenceParent.loopType == LoopType.Incremental) {
startValue += changeValue * (t.loopType == LoopType.Incremental ? t.loops : 1)
* (t.sequenceParent.isComplete ? t.sequenceParent.completedLoops - 1 : t.sequenceParent.completedLoops);
}
setter(startValue + changeValue * EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod));
}
}
}

View File

@ -331,6 +331,14 @@
<para>Example usage with lambda:</para><code>x=> myProperty = x</code></param> <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> <param name="endValue">The end value to reach</param><param name="duration">The tween's duration</param>
</member> </member>
<member name="M:DG.Tweening.DOTween.To(DG.Tweening.Core.DOGetter{System.Double},DG.Tweening.Core.DOSetter{System.Double},System.Single,System.Single)">
<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>
<param name="setter">A setter for the field or property to tween
<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>
</member>
<member name="M:DG.Tweening.DOTween.To(DG.Tweening.Core.DOGetter{System.Int32},DG.Tweening.Core.DOSetter{System.Int32},System.Int32,System.Single)"> <member name="M:DG.Tweening.DOTween.To(DG.Tweening.Core.DOGetter{System.Int32},DG.Tweening.Core.DOSetter{System.Int32},System.Int32,System.Single)">
<summary>Tweens a property or field to the given value using default plugins</summary> <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. <param name="getter">A getter for the field or property to tween.

Binary file not shown.

Binary file not shown.

Binary file not shown.