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

Added QuaternionSurrogate to make QuaternionPlugin fully compatible with Win8.1

This commit is contained in:
Daniele Giardini 2015-04-15 19:18:04 +02:00
parent 6ecc10cb6f
commit 9af3b701ea
56 changed files with 138 additions and 42 deletions

View File

@ -565,7 +565,7 @@
<param name="axisConstraint">Selecting an axis will tween the vector only on that axis, leaving the others untouched</param> <param name="axisConstraint">Selecting an axis will tween the vector only on that axis, leaving the others untouched</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member> </member>
<member name="M:DG.Tweening.TweenSettingsExtensions.SetOptions(DG.Tweening.Core.TweenerCore{UnityEngine.Quaternion,DG.Tweening.Core.Surrogates.Vector3Surrogate,DG.Tweening.Plugins.Options.QuaternionOptions},System.Boolean)"> <member name="M:DG.Tweening.TweenSettingsExtensions.SetOptions(DG.Tweening.Core.TweenerCore{DG.Tweening.Core.Surrogates.QuaternionSurrogate,DG.Tweening.Core.Surrogates.Vector3Surrogate,DG.Tweening.Plugins.Options.QuaternionOptions},System.Boolean)">
<summary>Options for Quaternion tweens</summary> <summary>Options for Quaternion tweens</summary>
<param name="useShortest360Route">If TRUE (default) the rotation will take the shortest route, and will not rotate more than 360°. <param name="useShortest360Route">If TRUE (default) the rotation will take the shortest route, and will not rotate more than 360°.
If FALSE the rotation will be fully accounted. Is always FALSE if the tween is set as relative</param> If FALSE the rotation will be fully accounted. Is always FALSE if the tween is set as relative</param>
@ -1520,7 +1520,7 @@
<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{UnityEngine.Quaternion},DG.Tweening.Core.DOSetter{UnityEngine.Quaternion},UnityEngine.Vector3,System.Single)"> <member name="M:DG.Tweening.DOTween.To(DG.Tweening.Core.DOGetter{DG.Tweening.Core.Surrogates.QuaternionSurrogate},DG.Tweening.Core.DOSetter{DG.Tweening.Core.Surrogates.QuaternionSurrogate},UnityEngine.Vector3,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.
<para>Example usage with lambda:</para><code>()=> myProperty</code></param> <para>Example usage with lambda:</para><code>()=> myProperty</code></param>

View File

@ -565,7 +565,7 @@
<param name="axisConstraint">Selecting an axis will tween the vector only on that axis, leaving the others untouched</param> <param name="axisConstraint">Selecting an axis will tween the vector only on that axis, leaving the others untouched</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member> </member>
<member name="M:DG.Tweening.TweenSettingsExtensions.SetOptions(DG.Tweening.Core.TweenerCore{UnityEngine.Quaternion,DG.Tweening.Core.Surrogates.Vector3Surrogate,DG.Tweening.Plugins.Options.QuaternionOptions},System.Boolean)"> <member name="M:DG.Tweening.TweenSettingsExtensions.SetOptions(DG.Tweening.Core.TweenerCore{DG.Tweening.Core.Surrogates.QuaternionSurrogate,DG.Tweening.Core.Surrogates.Vector3Surrogate,DG.Tweening.Plugins.Options.QuaternionOptions},System.Boolean)">
<summary>Options for Quaternion tweens</summary> <summary>Options for Quaternion tweens</summary>
<param name="useShortest360Route">If TRUE (default) the rotation will take the shortest route, and will not rotate more than 360°. <param name="useShortest360Route">If TRUE (default) the rotation will take the shortest route, and will not rotate more than 360°.
If FALSE the rotation will be fully accounted. Is always FALSE if the tween is set as relative</param> If FALSE the rotation will be fully accounted. Is always FALSE if the tween is set as relative</param>
@ -1520,7 +1520,7 @@
<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{UnityEngine.Quaternion},DG.Tweening.Core.DOSetter{UnityEngine.Quaternion},UnityEngine.Vector3,System.Single)"> <member name="M:DG.Tweening.DOTween.To(DG.Tweening.Core.DOGetter{DG.Tweening.Core.Surrogates.QuaternionSurrogate},DG.Tweening.Core.DOSetter{DG.Tweening.Core.Surrogates.QuaternionSurrogate},UnityEngine.Vector3,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.
<para>Example usage with lambda:</para><code>()=> myProperty</code></param> <para>Example usage with lambda:</para><code>()=> myProperty</code></param>

View File

@ -565,7 +565,7 @@
<param name="axisConstraint">Selecting an axis will tween the vector only on that axis, leaving the others untouched</param> <param name="axisConstraint">Selecting an axis will tween the vector only on that axis, leaving the others untouched</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member> </member>
<member name="M:DG.Tweening.TweenSettingsExtensions.SetOptions(DG.Tweening.Core.TweenerCore{UnityEngine.Quaternion,DG.Tweening.Core.Surrogates.Vector3Surrogate,DG.Tweening.Plugins.Options.QuaternionOptions},System.Boolean)"> <member name="M:DG.Tweening.TweenSettingsExtensions.SetOptions(DG.Tweening.Core.TweenerCore{DG.Tweening.Core.Surrogates.QuaternionSurrogate,DG.Tweening.Core.Surrogates.Vector3Surrogate,DG.Tweening.Plugins.Options.QuaternionOptions},System.Boolean)">
<summary>Options for Quaternion tweens</summary> <summary>Options for Quaternion tweens</summary>
<param name="useShortest360Route">If TRUE (default) the rotation will take the shortest route, and will not rotate more than 360°. <param name="useShortest360Route">If TRUE (default) the rotation will take the shortest route, and will not rotate more than 360°.
If FALSE the rotation will be fully accounted. Is always FALSE if the tween is set as relative</param> If FALSE the rotation will be fully accounted. Is always FALSE if the tween is set as relative</param>
@ -1520,7 +1520,7 @@
<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{UnityEngine.Quaternion},DG.Tweening.Core.DOSetter{UnityEngine.Quaternion},UnityEngine.Vector3,System.Single)"> <member name="M:DG.Tweening.DOTween.To(DG.Tweening.Core.DOGetter{DG.Tweening.Core.Surrogates.QuaternionSurrogate},DG.Tweening.Core.DOSetter{DG.Tweening.Core.Surrogates.QuaternionSurrogate},UnityEngine.Vector3,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.
<para>Example usage with lambda:</para><code>()=> myProperty</code></param> <para>Example usage with lambda:</para><code>()=> myProperty</code></param>

View File

@ -7,10 +7,22 @@ public class Temp : BrainBase
{ {
public RotateMode rotMode; public RotateMode rotMode;
public Transform target; public Transform target;
Sequence s;
IEnumerator Start() IEnumerator Start()
{ {
yield return new WaitForSeconds(0.6f); yield return new WaitForSeconds(0.6f);
target.DORotate(new Vector3(0,0,20f), 3f, rotMode).SetRelative(); s = DOTween.Sequence();
s.Insert(0.5f, target.DORotate(new Vector3(0,0,90f), 1f, rotMode).SetRelative());
s.Insert(1.5f, target.DORotate(new Vector3(0,90,0f), 1f, rotMode).SetRelative());
s.Insert(0.8f, target.DOMoveX(4, 1).SetRelative());
s.Insert(2f, target.DOMoveY(4, 1).SetRelative());
s.Pause();
}
void OnGUI()
{
if (GUILayout.Button("Play")) s.Play();
if (GUILayout.Button("Goto 2.5")) s.Goto(2.5f);
} }
} }

View File

@ -0,0 +1,67 @@
#if WP81
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2015/04/15 18:44
using UnityEngine;
#pragma warning disable 1591
namespace DG.Tweening.Core.Surrogates
{
public struct QuaternionSurrogate
{
public float x, y, z, w;
public QuaternionSurrogate(float x, float y, float z, float w)
{
this.x = x;
this.y = y;
this.z = z;
this.w = w;
}
#region Operations
public static QuaternionSurrogate operator *(QuaternionSurrogate lhs, QuaternionSurrogate rhs)
{
return new QuaternionSurrogate(lhs.w * rhs.x + lhs.x * rhs.w + lhs.y * rhs.z - lhs.z * rhs.y, lhs.w * rhs.y + lhs.y * rhs.w + lhs.z * rhs.x - lhs.x * rhs.z, lhs.w * rhs.z + lhs.z * rhs.w + lhs.x * rhs.y - lhs.y * rhs.x, lhs.w * rhs.w - lhs.x * rhs.x - lhs.y * rhs.y - lhs.z * rhs.z);
}
public static Vector3Surrogate operator *(QuaternionSurrogate rotation, Vector3Surrogate point)
{
float num = rotation.x * 2f;
float num2 = rotation.y * 2f;
float num3 = rotation.z * 2f;
float num4 = rotation.x * num;
float num5 = rotation.y * num2;
float num6 = rotation.z * num3;
float num7 = rotation.x * num2;
float num8 = rotation.x * num3;
float num9 = rotation.y * num3;
float num10 = rotation.w * num;
float num11 = rotation.w * num2;
float num12 = rotation.w * num3;
Vector3Surrogate result;
result.x = (1f - (num5 + num6)) * point.x + (num7 - num12) * point.y + (num8 + num11) * point.z;
result.y = (num7 + num12) * point.x + (1f - (num4 + num6)) * point.y + (num9 - num10) * point.z;
result.z = (num8 - num11) * point.x + (num9 + num10) * point.y + (1f - (num4 + num5)) * point.z;
return result;
}
#endregion
#region Conversions
public static implicit operator Quaternion(QuaternionSurrogate v)
{
return new Quaternion(v.x, v.y, v.z, v.w);
}
public static implicit operator QuaternionSurrogate(Quaternion v)
{
return new QuaternionSurrogate(v.x, v.y, v.z, v.w);
}
#endregion
}
}
#endif

View File

@ -24,7 +24,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.520"; public static readonly string Version = "1.0.521";
/////////////////////////////////////////////// ///////////////////////////////////////////////
// Options //////////////////////////////////// // Options ////////////////////////////////////
@ -347,8 +347,8 @@ namespace DG.Tweening
/// <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>
#if WP81 #if WP81
public static TweenerCore<Quaternion, Vector3Surrogate, QuaternionOptions> To(DOGetter<Quaternion> getter, DOSetter<Quaternion> setter, Vector3 endValue, float duration) public static TweenerCore<QuaternionSurrogate, Vector3Surrogate, QuaternionOptions> To(DOGetter<QuaternionSurrogate> getter, DOSetter<QuaternionSurrogate> setter, Vector3 endValue, float duration)
{ return ApplyTo<Quaternion, Vector3Surrogate, QuaternionOptions>(getter, setter, endValue, duration); } { return ApplyTo<QuaternionSurrogate, Vector3Surrogate, QuaternionOptions>(getter, setter, endValue, duration); }
#else #else
public static TweenerCore<Quaternion, Vector3, QuaternionOptions> To(DOGetter<Quaternion> getter, DOSetter<Quaternion> setter, Vector3 endValue, float duration) public static TweenerCore<Quaternion, Vector3, QuaternionOptions> To(DOGetter<Quaternion> getter, DOSetter<Quaternion> setter, Vector3 endValue, float duration)
{ return ApplyTo<Quaternion, Vector3, QuaternionOptions>(getter, setter, endValue, duration); } { return ApplyTo<Quaternion, Vector3, QuaternionOptions>(getter, setter, endValue, duration); }

View File

@ -72,6 +72,7 @@
<Compile Include="Core\Extensions.cs" /> <Compile Include="Core\Extensions.cs" />
<Compile Include="Core\SequenceCallback.cs" /> <Compile Include="Core\SequenceCallback.cs" />
<Compile Include="Core\Surrogates\ColorSurrogate.cs" /> <Compile Include="Core\Surrogates\ColorSurrogate.cs" />
<Compile Include="Core\Surrogates\QuaternionSurrogate.cs" />
<Compile Include="Core\Surrogates\Vector2Surrogate.cs" /> <Compile Include="Core\Surrogates\Vector2Surrogate.cs" />
<Compile Include="Core\Surrogates\Vector3Surrogate.cs" /> <Compile Include="Core\Surrogates\Vector3Surrogate.cs" />
<Compile Include="Core\TweenManager.cs" /> <Compile Include="Core\TweenManager.cs" />

View File

@ -64,17 +64,23 @@ namespace DG.Tweening.Plugins.Core
} }
} }
#endif #endif
else if (t1 == typeof(Quaternion)) { #if WP81
else if (t1 == typeof(QuaternionSurrogate)) {
if (t2 == typeof(Quaternion)) Debugger.LogError("Quaternion tweens require a Vector3 endValue"); if (t2 == typeof(Quaternion)) Debugger.LogError("Quaternion tweens require a Vector3 endValue");
else { else {
#if WP81
if (_quaternionPlugin == null) _quaternionPlugin = new QuaternionSurrogatePlugin(); if (_quaternionPlugin == null) _quaternionPlugin = new QuaternionSurrogatePlugin();
#else
if (_quaternionPlugin == null) _quaternionPlugin = new QuaternionPlugin();
#endif
plugin = _quaternionPlugin; plugin = _quaternionPlugin;
} }
} }
#else
else if (t1 == typeof(Quaternion)) {
if (t2 == typeof(Quaternion)) Debugger.LogError("Quaternion tweens require a Vector3 endValue");
else {
if (_quaternionPlugin == null) _quaternionPlugin = new QuaternionPlugin();
plugin = _quaternionPlugin;
}
}
#endif
#if WP81 #if WP81
else if (t1 == typeof(Vector2Surrogate)) { else if (t1 == typeof(Vector2Surrogate)) {
if (_vector2Plugin == null) _vector2Plugin = new Vector2SurrogatePlugin(); if (_vector2Plugin == null) _vector2Plugin = new Vector2SurrogatePlugin();

View File

@ -5,6 +5,7 @@
// This work is subject to the terms at http://dotween.demigiant.com/license.php // This work is subject to the terms at http://dotween.demigiant.com/license.php
using DG.Tweening.Core; using DG.Tweening.Core;
using DG.Tweening.Core.Surrogates;
using DG.Tweening.Plugins.Options; using DG.Tweening.Plugins.Options;
using UnityEngine; using UnityEngine;
@ -14,7 +15,11 @@ namespace DG.Tweening.Plugins.Core
internal static class SpecialPluginsUtils internal static class SpecialPluginsUtils
{ {
// Returns TRUE if it's successful, FALSE otherwise // Returns TRUE if it's successful, FALSE otherwise
#if WP81
internal static bool SetLookAt(TweenerCore<QuaternionSurrogate, Vector3Surrogate, QuaternionOptions> t)
#else
internal static bool SetLookAt(TweenerCore<Quaternion, Vector3, QuaternionOptions> t) internal static bool SetLookAt(TweenerCore<Quaternion, Vector3, QuaternionOptions> t)
#endif
{ {
Transform trans = t.target as Transform; Transform trans = t.target as Transform;
Vector3 towards = t.endValue; Vector3 towards = t.endValue;

View File

@ -12,41 +12,41 @@ using UnityEngine;
#pragma warning disable 1591 #pragma warning disable 1591
namespace DG.Tweening.Plugins namespace DG.Tweening.Plugins
{ {
public class QuaternionSurrogatePlugin : ABSTweenPlugin<Quaternion, Vector3Surrogate, QuaternionOptions> public class QuaternionSurrogatePlugin : ABSTweenPlugin<QuaternionSurrogate, Vector3Surrogate, QuaternionOptions>
{ {
public override void Reset(TweenerCore<Quaternion, Vector3Surrogate, QuaternionOptions> t) { } public override void Reset(TweenerCore<QuaternionSurrogate, Vector3Surrogate, QuaternionOptions> t) { }
public override void SetFrom(TweenerCore<Quaternion, Vector3Surrogate, QuaternionOptions> t, bool isRelative) public override void SetFrom(TweenerCore<QuaternionSurrogate, Vector3Surrogate, QuaternionOptions> t, bool isRelative)
{ {
Vector3Surrogate prevEndVal = t.endValue; Vector3Surrogate prevEndVal = t.endValue;
t.endValue = t.getter().eulerAngles; t.endValue = ((Quaternion)t.getter()).eulerAngles;
if (t.plugOptions.rotateMode == RotateMode.Fast && !t.isRelative) { if (t.plugOptions.rotateMode == RotateMode.Fast && !t.isRelative) {
t.startValue = prevEndVal; t.startValue = prevEndVal;
} else if (t.plugOptions.rotateMode == RotateMode.FastBeyond360) { } else if (t.plugOptions.rotateMode == RotateMode.FastBeyond360) {
t.startValue = t.endValue + prevEndVal; t.startValue = t.endValue + prevEndVal;
} else { } else {
Quaternion rot = t.getter(); QuaternionSurrogate rot = t.getter();
if (t.plugOptions.rotateMode == RotateMode.WorldAxisAdd) { if (t.plugOptions.rotateMode == RotateMode.WorldAxisAdd) {
t.startValue = (rot * Quaternion.Inverse(rot) * Quaternion.Euler(prevEndVal) * rot).eulerAngles; t.startValue = ((Quaternion)rot * Quaternion.Inverse(rot) * Quaternion.Euler(prevEndVal) * (Quaternion)rot).eulerAngles;
} else { } else {
t.startValue = (rot * Quaternion.Euler(prevEndVal)).eulerAngles; t.startValue = ((Quaternion)rot * Quaternion.Euler(prevEndVal)).eulerAngles;
} }
t.endValue = -prevEndVal; t.endValue = -prevEndVal;
} }
t.setter(Quaternion.Euler(t.startValue)); t.setter(Quaternion.Euler(t.startValue));
} }
public override Vector3Surrogate ConvertToStartValue(TweenerCore<Quaternion, Vector3Surrogate, QuaternionOptions> t, Quaternion value) public override Vector3Surrogate ConvertToStartValue(TweenerCore<QuaternionSurrogate, Vector3Surrogate, QuaternionOptions> t, QuaternionSurrogate value)
{ {
return value.eulerAngles; return ((Quaternion)value).eulerAngles;
} }
public override void SetRelativeEndValue(TweenerCore<Quaternion, Vector3Surrogate, QuaternionOptions> t) public override void SetRelativeEndValue(TweenerCore<QuaternionSurrogate, Vector3Surrogate, QuaternionOptions> t)
{ {
t.endValue += t.startValue; t.endValue += t.startValue;
} }
public override void SetChangeValue(TweenerCore<Quaternion, Vector3Surrogate, QuaternionOptions> t) public override void SetChangeValue(TweenerCore<QuaternionSurrogate, Vector3Surrogate, QuaternionOptions> t)
{ {
if (t.plugOptions.rotateMode == RotateMode.Fast && !t.isRelative) { if (t.plugOptions.rotateMode == RotateMode.Fast && !t.isRelative) {
// Rotation will be adapted to 360° and will take the shortest route // Rotation will be adapted to 360° and will take the shortest route
@ -77,7 +77,7 @@ namespace DG.Tweening.Plugins
return changeValue.magnitude / unitsXSecond; return changeValue.magnitude / unitsXSecond;
} }
public override void EvaluateAndApply(QuaternionOptions options, Tween t, bool isRelative, DOGetter<Quaternion> getter, DOSetter<Quaternion> setter, float elapsed, Vector3Surrogate startValue, Vector3Surrogate changeValue, float duration, bool usingInversePosition) public override void EvaluateAndApply(QuaternionOptions options, Tween t, bool isRelative, DOGetter<QuaternionSurrogate> getter, DOSetter<QuaternionSurrogate> setter, float elapsed, Vector3Surrogate startValue, Vector3Surrogate changeValue, float duration, bool usingInversePosition)
{ {
Vector3Surrogate endValue = startValue; Vector3Surrogate endValue = startValue;
@ -91,12 +91,12 @@ namespace DG.Tweening.Plugins
switch (options.rotateMode) { switch (options.rotateMode) {
case RotateMode.WorldAxisAdd: case RotateMode.WorldAxisAdd:
case RotateMode.LocalAxisAdd: case RotateMode.LocalAxisAdd:
Quaternion startRot = Quaternion.Euler(startValue); // Reset rotation QuaternionSurrogate startRot = Quaternion.Euler(startValue); // Reset rotation
endValue.x = changeValue.x * easeVal; endValue.x = changeValue.x * easeVal;
endValue.y = changeValue.y * easeVal; endValue.y = changeValue.y * easeVal;
endValue.z = changeValue.z * easeVal; endValue.z = changeValue.z * easeVal;
if (options.rotateMode == RotateMode.WorldAxisAdd) setter(startRot * Quaternion.Inverse(startRot) * Quaternion.Euler(endValue) * startRot); if (options.rotateMode == RotateMode.WorldAxisAdd) setter((Quaternion)startRot * Quaternion.Inverse(startRot) * Quaternion.Euler(endValue) * (Quaternion)startRot);
else setter(startRot * Quaternion.Euler(endValue)); else setter((Quaternion)startRot * Quaternion.Euler(endValue));
break; break;
default: default:
endValue.x += changeValue.x * easeVal; endValue.x += changeValue.x * easeVal;

View File

@ -295,7 +295,7 @@ namespace DG.Tweening
public static Tweener DORotate(this Rigidbody target, Vector3 endValue, float duration, RotateMode mode = RotateMode.Fast) public static Tweener DORotate(this Rigidbody target, Vector3 endValue, float duration, RotateMode mode = RotateMode.Fast)
{ {
#if WP81 #if WP81
TweenerCore<Quaternion, Vector3Surrogate, QuaternionOptions> t = DOTween.To(() => target.rotation, target.MoveRotation, endValue, duration); TweenerCore<QuaternionSurrogate, Vector3Surrogate, QuaternionOptions> t = DOTween.To(() => target.rotation, x => target.MoveRotation(x), endValue, duration);
#else #else
TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => target.rotation, target.MoveRotation, endValue, duration); TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => target.rotation, target.MoveRotation, endValue, duration);
#endif #endif
@ -312,7 +312,7 @@ namespace DG.Tweening
public static Tweener DOLookAt(this Rigidbody target, Vector3 towards, float duration, AxisConstraint axisConstraint = AxisConstraint.None, Vector3? up = null) public static Tweener DOLookAt(this Rigidbody target, Vector3 towards, float duration, AxisConstraint axisConstraint = AxisConstraint.None, Vector3? up = null)
{ {
#if WP81 #if WP81
TweenerCore<Quaternion, Vector3Surrogate, QuaternionOptions> t = DOTween.To(() => target.rotation, target.MoveRotation, towards, duration) TweenerCore<QuaternionSurrogate, Vector3Surrogate, QuaternionOptions> t = DOTween.To(() => target.rotation, x => target.MoveRotation(x), towards, duration)
#else #else
TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => target.rotation, target.MoveRotation, towards, duration) TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => target.rotation, target.MoveRotation, towards, duration)
#endif #endif
@ -439,7 +439,7 @@ namespace DG.Tweening
public static Tweener DORotate(this Transform target, Vector3 endValue, float duration, RotateMode mode = RotateMode.Fast) public static Tweener DORotate(this Transform target, Vector3 endValue, float duration, RotateMode mode = RotateMode.Fast)
{ {
#if WP81 #if WP81
TweenerCore<Quaternion, Vector3Surrogate, QuaternionOptions> t = DOTween.To(() => target.rotation, x => target.rotation = x, endValue, duration); TweenerCore<QuaternionSurrogate, Vector3Surrogate, QuaternionOptions> t = DOTween.To(() => target.rotation, x => target.rotation = x, endValue, duration);
#else #else
TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => target.rotation, x => target.rotation = x, endValue, duration); TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => target.rotation, x => target.rotation = x, endValue, duration);
#endif #endif
@ -455,7 +455,7 @@ namespace DG.Tweening
public static Tweener DOLocalRotate(this Transform target, Vector3 endValue, float duration, RotateMode mode = RotateMode.Fast) public static Tweener DOLocalRotate(this Transform target, Vector3 endValue, float duration, RotateMode mode = RotateMode.Fast)
{ {
#if WP81 #if WP81
TweenerCore<Quaternion, Vector3Surrogate, QuaternionOptions> t = DOTween.To(() => target.localRotation, x => target.localRotation = x, endValue, duration); TweenerCore<QuaternionSurrogate, Vector3Surrogate, QuaternionOptions> t = DOTween.To(() => target.localRotation, x => target.localRotation = x, endValue, duration);
#else #else
TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => target.localRotation, x => target.localRotation = x, endValue, duration); TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => target.localRotation, x => target.localRotation = x, endValue, duration);
#endif #endif
@ -519,7 +519,7 @@ namespace DG.Tweening
public static Tweener DOLookAt(this Transform target, Vector3 towards, float duration, AxisConstraint axisConstraint = AxisConstraint.None, Vector3? up = null) public static Tweener DOLookAt(this Transform target, Vector3 towards, float duration, AxisConstraint axisConstraint = AxisConstraint.None, Vector3? up = null)
{ {
#if WP81 #if WP81
TweenerCore<Quaternion, Vector3Surrogate, QuaternionOptions> t = DOTween.To(() => target.rotation, x => target.rotation = x, towards, duration) TweenerCore<QuaternionSurrogate, Vector3Surrogate, QuaternionOptions> t = DOTween.To(() => target.rotation, x => target.rotation = x, towards, duration)
#else #else
TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => target.rotation, x => target.rotation = x, towards, duration) TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => target.rotation, x => target.rotation = x, towards, duration)
#endif #endif
@ -767,11 +767,11 @@ namespace DG.Tweening
{ {
Quaternion to = target.rotation; Quaternion to = target.rotation;
#if WP81 #if WP81
TweenerCore<Quaternion, Vector3Surrogate, QuaternionOptions> t = DOTween.To(() => to, x => { TweenerCore<QuaternionSurrogate, Vector3Surrogate, QuaternionOptions> t = DOTween.To(() => to, x => {
#else #else
TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => to, x => { TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => to, x => {
#endif #endif
Quaternion diff = x * Quaternion.Inverse(to); Quaternion diff = (Quaternion)x * Quaternion.Inverse(to);
to = x; to = x;
target.rotation = target.rotation * Quaternion.Inverse(target.rotation) * diff * target.rotation; target.rotation = target.rotation * Quaternion.Inverse(target.rotation) * diff * target.rotation;
}, byValue, duration) }, byValue, duration)
@ -790,11 +790,11 @@ namespace DG.Tweening
{ {
Quaternion to = target.localRotation; Quaternion to = target.localRotation;
#if WP81 #if WP81
TweenerCore<Quaternion, Vector3Surrogate, QuaternionOptions> t = DOTween.To(() => to, x => { TweenerCore<QuaternionSurrogate, Vector3Surrogate, QuaternionOptions> t = DOTween.To(() => to, x => {
#else #else
TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => to, x => { TweenerCore<Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => to, x => {
#endif #endif
Quaternion diff = x * Quaternion.Inverse(to); Quaternion diff = (Quaternion)x * Quaternion.Inverse(to);
to = x; to = x;
target.localRotation = target.localRotation * Quaternion.Inverse(target.localRotation) * diff * target.localRotation; target.localRotation = target.localRotation * Quaternion.Inverse(target.localRotation) * diff * target.localRotation;
}, byValue, duration) }, byValue, duration)

View File

@ -673,7 +673,7 @@ namespace DG.Tweening
/// <param name="useShortest360Route">If TRUE (default) the rotation will take the shortest route, and will not rotate more than 360°. /// <param name="useShortest360Route">If TRUE (default) the rotation will take the shortest route, and will not rotate more than 360°.
/// If FALSE the rotation will be fully accounted. Is always FALSE if the tween is set as relative</param> /// If FALSE the rotation will be fully accounted. Is always FALSE if the tween is set as relative</param>
#if WP81 #if WP81
public static Tweener SetOptions(this TweenerCore<Quaternion, Vector3Surrogate, QuaternionOptions> t, bool useShortest360Route = true) public static Tweener SetOptions(this TweenerCore<QuaternionSurrogate, Vector3Surrogate, QuaternionOptions> t, bool useShortest360Route = true)
#else #else
public static Tweener SetOptions(this TweenerCore<Quaternion, Vector3, QuaternionOptions> t, bool useShortest360Route = true) public static Tweener SetOptions(this TweenerCore<Quaternion, Vector3, QuaternionOptions> t, bool useShortest360Route = true)
#endif #endif

View File

@ -7,6 +7,7 @@
using System; using System;
using DG.Tweening.Core; using DG.Tweening.Core;
using DG.Tweening.Core.Enums; using DG.Tweening.Core.Enums;
using DG.Tweening.Core.Surrogates;
using DG.Tweening.Plugins.Core; using DG.Tweening.Plugins.Core;
using DG.Tweening.Plugins.Options; using DG.Tweening.Plugins.Options;
using UnityEngine; using UnityEngine;
@ -283,7 +284,11 @@ namespace DG.Tweening
try { try {
switch (t.specialStartupMode) { switch (t.specialStartupMode) {
case SpecialStartupMode.SetLookAt: case SpecialStartupMode.SetLookAt:
#if WP81
if (!SpecialPluginsUtils.SetLookAt(t as TweenerCore<QuaternionSurrogate, Vector3Surrogate, QuaternionOptions>)) return false;
#else
if (!SpecialPluginsUtils.SetLookAt(t as TweenerCore<Quaternion, Vector3, QuaternionOptions>)) return false; if (!SpecialPluginsUtils.SetLookAt(t as TweenerCore<Quaternion, Vector3, QuaternionOptions>)) return false;
#endif
break; break;
case SpecialStartupMode.SetPunch: case SpecialStartupMode.SetPunch:
if (!SpecialPluginsUtils.SetPunch(t as TweenerCore<Vector3, Vector3[], Vector3ArrayOptions>)) return false; if (!SpecialPluginsUtils.SetPunch(t as TweenerCore<Vector3, Vector3[], Vector3ArrayOptions>)) return false;

View File

@ -565,7 +565,7 @@
<param name="axisConstraint">Selecting an axis will tween the vector only on that axis, leaving the others untouched</param> <param name="axisConstraint">Selecting an axis will tween the vector only on that axis, leaving the others untouched</param>
<param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
</member> </member>
<member name="M:DG.Tweening.TweenSettingsExtensions.SetOptions(DG.Tweening.Core.TweenerCore{UnityEngine.Quaternion,DG.Tweening.Core.Surrogates.Vector3Surrogate,DG.Tweening.Plugins.Options.QuaternionOptions},System.Boolean)"> <member name="M:DG.Tweening.TweenSettingsExtensions.SetOptions(DG.Tweening.Core.TweenerCore{DG.Tweening.Core.Surrogates.QuaternionSurrogate,DG.Tweening.Core.Surrogates.Vector3Surrogate,DG.Tweening.Plugins.Options.QuaternionOptions},System.Boolean)">
<summary>Options for Quaternion tweens</summary> <summary>Options for Quaternion tweens</summary>
<param name="useShortest360Route">If TRUE (default) the rotation will take the shortest route, and will not rotate more than 360°. <param name="useShortest360Route">If TRUE (default) the rotation will take the shortest route, and will not rotate more than 360°.
If FALSE the rotation will be fully accounted. Is always FALSE if the tween is set as relative</param> If FALSE the rotation will be fully accounted. Is always FALSE if the tween is set as relative</param>
@ -1520,7 +1520,7 @@
<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{UnityEngine.Quaternion},DG.Tweening.Core.DOSetter{UnityEngine.Quaternion},UnityEngine.Vector3,System.Single)"> <member name="M:DG.Tweening.DOTween.To(DG.Tweening.Core.DOGetter{DG.Tweening.Core.Surrogates.QuaternionSurrogate},DG.Tweening.Core.DOSetter{DG.Tweening.Core.Surrogates.QuaternionSurrogate},UnityEngine.Vector3,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.
<para>Example usage with lambda:</para><code>()=> myProperty</code></param> <para>Example usage with lambda:</para><code>()=> myProperty</code></param>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.