1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-20 09:16:02 +08:00

Implementing Vector2/3/4 surrogates that don't break C# rules as Unity does, so they will work on WP8.1

This commit is contained in:
Daniele Giardini 2015-04-14 12:51:04 +02:00
parent 531bd3409b
commit eb74216d6a
9 changed files with 685 additions and 80 deletions

View File

@ -0,0 +1,58 @@
#if WP81
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2015/04/14 12:42
using UnityEngine;
#pragma warning disable 1591
namespace DG.Tweening.Core.Surrogates
{
/// <summary>
/// A surrogate for Vector2/3/4 values to work around Unity's bug when trying to cast to
/// a Vector2/3/4 plugin on WP8.1
/// </summary>
public struct Vector2Surrogate
{
public float x, y;
public float magnitude {
get { return Mathf.Sqrt(x * x + y * y); }
}
public Vector2Surrogate(float x, float y)
: this()
{
this.x = x;
this.y = y;
}
#region Operations
public static Vector2Surrogate operator +(Vector2Surrogate v1, Vector2Surrogate v2)
{
return new Vector2Surrogate(v1.x + v2.x, v1.y + v2.y);
}
public static Vector2Surrogate operator -(Vector2Surrogate v1, Vector2Surrogate v2)
{
return new Vector2Surrogate(v1.x - v2.x, v1.y - v2.y);
}
public static Vector2Surrogate operator *(Vector2Surrogate v1, float f)
{
return new Vector2Surrogate(v1.x * f, v1.y * f);
}
#endregion
#region Conversions
public static explicit operator Vector3(Vector2Surrogate v)
{
return new Vector3(v.x, v.y);
}
#endregion
}
}
#endif

View File

@ -0,0 +1,59 @@
#if WP81
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2015/04/14 12:37
using UnityEngine;
#pragma warning disable 1591
namespace DG.Tweening.Core.Surrogates
{
/// <summary>
/// A surrogate for Vector2/3/4 values to work around Unity's bug when trying to cast to
/// a Vector2/3/4 plugin on WP8.1
/// </summary>
public struct Vector3Surrogate
{
public float x, y, z;
public float magnitude {
get { return Mathf.Sqrt(x * x + y * y + z * z); }
}
public Vector3Surrogate(float x, float y, float z)
: this()
{
this.x = x;
this.y = y;
this.z = z;
}
#region Operations
public static Vector3Surrogate operator +(Vector3Surrogate v1, Vector3Surrogate v2)
{
return new Vector3Surrogate(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
}
public static Vector3Surrogate operator -(Vector3Surrogate v1, Vector3Surrogate v2)
{
return new Vector3Surrogate(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
}
public static Vector3Surrogate operator *(Vector3Surrogate v1, float f)
{
return new Vector3Surrogate(v1.x * f, v1.y * f, v1.z * f);
}
#endregion
#region Conversions
public static explicit operator Vector3(Vector3Surrogate v)
{
return new Vector3(v.x, v.y, v.z);
}
#endregion
}
}
#endif

View File

@ -0,0 +1,108 @@
#if WP81
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2015/04/14 12:10
using UnityEngine;
#pragma warning disable 1591
namespace DG.Tweening.Core.Surrogates
{
/// <summary>
/// A surrogate for Vector2/3/4 values to work around Unity's bug when trying to cast to
/// a Vector2/3/4 plugin on WP8.1
/// </summary>
public struct Vector4Surrogate
{
public float x, y, z, w;
public float magnitude {
get { return Mathf.Sqrt(x * x + y * y + z * z + w * w); }
}
public Vector4Surrogate(float x, float y, float z, float w)
{
this.x = x;
this.y = y;
this.z = z;
this.w = w;
}
#region Operations
public static Vector4Surrogate operator +(Vector4Surrogate v1, Vector4Surrogate v2)
{
return new Vector4Surrogate(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z, v1.w + v2.w);
}
public static Vector4Surrogate operator -(Vector4Surrogate v1, Vector4Surrogate v2)
{
return new Vector4Surrogate(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z, v1.w - v2.w);
}
public static Vector4Surrogate operator *(Vector4Surrogate v1, float f)
{
return new Vector4Surrogate(v1.x * f, v1.y * f, v1.z * f, v1.w * f);
}
// public static Vector4Surrogate operator /(Vector4Surrogate v1, float f)
// {
// return new Vector4Surrogate(v1.x / f, v1.y / f, v1.z / f, v1.w / f);
// }
#endregion
#region Comparisons
// public static bool operator <(Vector4Surrogate v1, Vector4Surrogate v2)
// {
// return v1.magnitude < v2.magnitude;
// }
//
// public static bool operator <=(Vector4Surrogate v1, Vector4Surrogate v2)
// {
// return v1.magnitude <= v2.magnitude;
// }
//
// public static bool operator >(Vector4Surrogate v1, Vector4Surrogate v2)
// {
// return v1.magnitude > v2.magnitude;
// }
//
// public static bool operator >=(Vector4Surrogate v1, Vector4Surrogate v2)
// {
// return v1.magnitude >= v2.magnitude;
// }
//
// public static bool operator ==(Vector4Surrogate v1, Vector4Surrogate v2)
// {
// return v1.x == v2.x && v1.y == v2.y && v1.z == v2.z && v1.w == v2.w;
// }
//
// public static bool operator !=(Vector4Surrogate v1, Vector4Surrogate v2)
// {
// return !(v1 == v2);
// }
#endregion
#region Conversions
// public static explicit operator Vector2(Vector4Surrogate v)
// {
// return new Vector2(v.x, v.y);
// }
//
// public static explicit operator Vector3(Vector4Surrogate v)
// {
// return new Vector3(v.x, v.y, v.z);
// }
public static explicit operator Vector4(Vector4Surrogate v)
{
return new Vector4(v.x, v.y, v.z, v.w);
}
#endregion
}
}
#endif

View File

@ -73,6 +73,7 @@
<Compile Include="Core\SequenceCallback.cs" />
<Compile Include="Core\TweenManager.cs" />
<Compile Include="Core\Utils.cs" />
<Compile Include="Core\Surrogates\Vector4Surrogate.cs" />
<Compile Include="DOTween.cs" />
<Compile Include="DOVirtual.cs" />
<Compile Include="Ease.cs" />
@ -95,6 +96,7 @@
<Compile Include="Plugins\Core\PathCore\LinearDecoder.cs" />
<Compile Include="Plugins\Core\PathCore\Path.cs" />
<Compile Include="Plugins\PathPlugin.cs" />
<Compile Include="Plugins\Vector4SurrogatePlugin.cs" />
<Compile Include="RotateMode.cs" />
<Compile Include="ScrambleMode.cs" />
<Compile Include="TweenExtensions.cs" />

View File

@ -99,61 +99,62 @@ namespace DG.Tweening.Plugins.Core
#if !WP81
if (plugin != null) return plugin as ABSTweenPlugin<T1, T2, TPlugOptions>;
#else
if (plugin != null) return plugin as ABSTweenPlugin<T1, T2, TPlugOptions>;
// WP8.1 fix tries
if (plugin != null) {
Debug.Log("PLUGIN FOUND, trying to assign it correctly...");
ABSTweenPlugin<T1, T2, TPlugOptions> p;
ABSTweenPlugin<Vector3, Vector3, VectorOptions> pExplicit;
// Explicit casting to Vector3Plugin
try {
pExplicit = (ABSTweenPlugin<Vector3, Vector3, VectorOptions>)plugin;
if (pExplicit != null) Debug.Log("- EXPLICIT CAST SUCCESS X");
p = pExplicit as ABSTweenPlugin<T1, T2, TPlugOptions>;
if (p != null) {
Debug.Log("- PLUGIN SUCCESS X");
return p;
}
} catch (Exception e) {
Debug.Log("- PLUGIN FAIL X > " + e.Message);
}
// More regular ways
try {
p = plugin as ABSTweenPlugin<T1, T2, TPlugOptions>;
if (p != null) {
Debug.Log("- PLUGIN SUCCESS A");
return p;
}
} catch (Exception e) {
Debug.Log("- PLUGIN FAIL A > " + e.Message);
}
try {
System.Object obj = (object)plugin;
p = obj as ABSTweenPlugin<T1, T2, TPlugOptions>;
if (p != null) {
Debug.Log("- PLUGIN SUCCESS A2");
return p;
}
} catch (Exception e) {
Debug.Log("- PLUGIN FAIL A2 > " + e.Message);
}
try {
p = (ABSTweenPlugin<T1, T2, TPlugOptions>)plugin;
Debug.Log("- PLUGIN SUCCESS B");
return p;
} catch (Exception e) {
Debug.Log("- PLUGIN FAIL B > " + e.Message);
}
try {
System.Object obj = (object)plugin;
p = (ABSTweenPlugin<T1, T2, TPlugOptions>)obj;
Debug.Log("- PLUGIN SUCCESS B2");
return p;
} catch (Exception e) {
Debug.Log("- PLUGIN FAIL B2 > " + e.Message);
}
return null;
}
Debug.Log("PLUGIN NOT FOUND");
// if (plugin != null) {
// Debug.Log("PLUGIN FOUND, trying to assign it correctly...");
// ABSTweenPlugin<T1, T2, TPlugOptions> p;
// ABSTweenPlugin<Vector3, Vector3, VectorOptions> pExplicit;
// // Explicit casting to Vector3Plugin
// try {
// pExplicit = (ABSTweenPlugin<Vector3, Vector3, VectorOptions>)plugin;
// if (pExplicit != null) Debug.Log("- EXPLICIT CAST SUCCESS X");
// p = pExplicit as ABSTweenPlugin<T1, T2, TPlugOptions>;
// if (p != null) {
// Debug.Log("- PLUGIN SUCCESS X");
// return p;
// }
// } catch (Exception e) {
// Debug.Log("- PLUGIN FAIL X > " + e.Message);
// }
// // More regular ways
// try {
// p = plugin as ABSTweenPlugin<T1, T2, TPlugOptions>;
// if (p != null) {
// Debug.Log("- PLUGIN SUCCESS A");
// return p;
// }
// } catch (Exception e) {
// Debug.Log("- PLUGIN FAIL A > " + e.Message);
// }
// try {
// System.Object obj = (object)plugin;
// p = obj as ABSTweenPlugin<T1, T2, TPlugOptions>;
// if (p != null) {
// Debug.Log("- PLUGIN SUCCESS A2");
// return p;
// }
// } catch (Exception e) {
// Debug.Log("- PLUGIN FAIL A2 > " + e.Message);
// }
// try {
// p = (ABSTweenPlugin<T1, T2, TPlugOptions>)plugin;
// Debug.Log("- PLUGIN SUCCESS B");
// return p;
// } catch (Exception e) {
// Debug.Log("- PLUGIN FAIL B > " + e.Message);
// }
// try {
// System.Object obj = (object)plugin;
// p = (ABSTweenPlugin<T1, T2, TPlugOptions>)obj;
// Debug.Log("- PLUGIN SUCCESS B2");
// return p;
// } catch (Exception e) {
// Debug.Log("- PLUGIN FAIL B2 > " + e.Message);
// }
// return null;
// }
// Debug.Log("PLUGIN NOT FOUND");
// WP8.1 fix tries END
#endif

View File

@ -0,0 +1,109 @@
#if WP81
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2015/04/14 12:46
using System;
using DG.Tweening.Core;
using DG.Tweening.Core.Easing;
using DG.Tweening.Core.Surrogates;
using DG.Tweening.Plugins.Core;
using DG.Tweening.Plugins.Options;
using UnityEngine;
#pragma warning disable 1591
namespace DG.Tweening.Plugins
{
public class Vector2SurrogatePlugin : ABSTweenPlugin<Vector2Surrogate, Vector2Surrogate, VectorOptions>
{
public override void Reset(TweenerCore<Vector2Surrogate, Vector2Surrogate, VectorOptions> t) { }
public override void SetFrom(TweenerCore<Vector2Surrogate, Vector2Surrogate, VectorOptions> t, bool isRelative)
{
Vector2Surrogate prevEndVal = t.endValue;
t.endValue = t.getter();
t.startValue = isRelative ? t.endValue + prevEndVal : prevEndVal;
Vector2Surrogate to = t.endValue;
switch (t.plugOptions.axisConstraint) {
case AxisConstraint.X:
to.x = t.startValue.x;
break;
case AxisConstraint.Y:
to.y = t.startValue.y;
break;
default:
to = t.startValue;
break;
}
if (t.plugOptions.snapping) {
to.x = (float)Math.Round(to.x);
to.y = (float)Math.Round(to.y);
}
t.setter(to);
}
public override Vector2Surrogate ConvertToStartValue(TweenerCore<Vector2Surrogate, Vector2Surrogate, VectorOptions> t, Vector2Surrogate value)
{
return value;
}
public override void SetRelativeEndValue(TweenerCore<Vector2Surrogate, Vector2Surrogate, VectorOptions> t)
{
t.endValue += t.startValue;
}
public override void SetChangeValue(TweenerCore<Vector2Surrogate, Vector2Surrogate, VectorOptions> t)
{
switch (t.plugOptions.axisConstraint) {
case AxisConstraint.X:
t.changeValue = new Vector2Surrogate(t.endValue.x - t.startValue.x, 0);
break;
case AxisConstraint.Y:
t.changeValue = new Vector2Surrogate(0, t.endValue.y - t.startValue.y);
break;
default:
t.changeValue = t.endValue - t.startValue;
break;
}
}
public override float GetSpeedBasedDuration(VectorOptions options, float unitsXSecond, Vector2Surrogate changeValue)
{
return changeValue.magnitude / unitsXSecond;
}
public override void EvaluateAndApply(VectorOptions options, Tween t, bool isRelative, DOGetter<Vector2Surrogate> getter, DOSetter<Vector2Surrogate> setter, float elapsed, Vector2Surrogate startValue, Vector2Surrogate changeValue, float duration, bool usingInversePosition)
{
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);
}
float easeVal = EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod);
switch (options.axisConstraint) {
case AxisConstraint.X:
Vector2Surrogate resX = getter();
resX.x = startValue.x + changeValue.x * easeVal;
if (options.snapping) resX.x = (float)Math.Round(resX.x);
setter(resX);
break;
case AxisConstraint.Y:
Vector2Surrogate resY = getter();
resY.y = startValue.y + changeValue.y * easeVal;
if (options.snapping) resY.y = (float)Math.Round(resY.y);
setter(resY);
break;
default:
startValue.x += changeValue.x * easeVal;
startValue.y += changeValue.y * easeVal;
if (options.snapping) {
startValue.x = (float)Math.Round(startValue.x);
startValue.y = (float)Math.Round(startValue.y);
}
setter(startValue);
break;
}
}
}
}
#endif

View File

@ -0,0 +1,123 @@
#if WP81
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2015/04/14 12:44
using System;
using DG.Tweening.Core;
using DG.Tweening.Core.Easing;
using DG.Tweening.Core.Surrogates;
using DG.Tweening.Plugins.Core;
using DG.Tweening.Plugins.Options;
#pragma warning disable 1591
namespace DG.Tweening.Plugins
{
public class Vector3SurrogatePlugin : ABSTweenPlugin<Vector3Surrogate, Vector3Surrogate, VectorOptions>
{
public override void Reset(TweenerCore<Vector3Surrogate, Vector3Surrogate, VectorOptions> t) { }
public override void SetFrom(TweenerCore<Vector3Surrogate, Vector3Surrogate, VectorOptions> t, bool isRelative)
{
Vector3Surrogate prevEndVal = t.endValue;
t.endValue = t.getter();
t.startValue = isRelative ? t.endValue + prevEndVal : prevEndVal;
Vector3Surrogate to = t.endValue;
switch (t.plugOptions.axisConstraint) {
case AxisConstraint.X:
to.x = t.startValue.x;
break;
case AxisConstraint.Y:
to.y = t.startValue.y;
break;
case AxisConstraint.Z:
to.z = t.startValue.z;
break;
default:
to = t.startValue;
break;
}
if (t.plugOptions.snapping) {
to.x = (float)Math.Round(to.x);
to.y = (float)Math.Round(to.y);
to.z = (float)Math.Round(to.z);
}
t.setter(to);
}
public override Vector3Surrogate ConvertToStartValue(TweenerCore<Vector3Surrogate, Vector3Surrogate, VectorOptions> t, Vector3Surrogate value)
{
return value;
}
public override void SetRelativeEndValue(TweenerCore<Vector3Surrogate, Vector3Surrogate, VectorOptions> t)
{
t.endValue += t.startValue;
}
public override void SetChangeValue(TweenerCore<Vector3Surrogate, Vector3Surrogate, VectorOptions> t)
{
switch (t.plugOptions.axisConstraint) {
case AxisConstraint.X:
t.changeValue = new Vector3Surrogate(t.endValue.x - t.startValue.x, 0, 0);
break;
case AxisConstraint.Y:
t.changeValue = new Vector3Surrogate(0, t.endValue.y - t.startValue.y, 0);
break;
case AxisConstraint.Z:
t.changeValue = new Vector3Surrogate(0, 0, t.endValue.z - t.startValue.z);
break;
default:
t.changeValue = t.endValue - t.startValue;
break;
}
}
public override float GetSpeedBasedDuration(VectorOptions options, float unitsXSecond, Vector3Surrogate changeValue)
{
return changeValue.magnitude / unitsXSecond;
}
public override void EvaluateAndApply(VectorOptions options, Tween t, bool isRelative, DOGetter<Vector3Surrogate> getter, DOSetter<Vector3Surrogate> setter, float elapsed, Vector3Surrogate startValue, Vector3Surrogate changeValue, float duration, bool usingInversePosition)
{
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);
}
float easeVal = EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod);
switch (options.axisConstraint) {
case AxisConstraint.X:
Vector3Surrogate resX = getter();
resX.x = startValue.x + changeValue.x * easeVal;
if (options.snapping) resX.x = (float)Math.Round(resX.x);
setter(resX);
break;
case AxisConstraint.Y:
Vector3Surrogate resY = getter();
resY.y = startValue.y + changeValue.y * easeVal;
if (options.snapping) resY.y = (float)Math.Round(resY.y);
setter(resY);
break;
case AxisConstraint.Z:
Vector3Surrogate resZ = getter();
resZ.z = startValue.z + changeValue.z * easeVal;
if (options.snapping) resZ.z = (float)Math.Round(resZ.z);
setter(resZ);
break;
default:
startValue.x += changeValue.x * easeVal;
startValue.y += changeValue.y * easeVal;
startValue.z += changeValue.z * easeVal;
if (options.snapping) {
startValue.x = (float)Math.Round(startValue.x);
startValue.y = (float)Math.Round(startValue.y);
startValue.z = (float)Math.Round(startValue.z);
}
setter(startValue);
break;
}
}
}
}
#endif

View File

@ -0,0 +1,139 @@
#if WP81
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2015/04/14 12:19
using System;
using DG.Tweening.Core;
using DG.Tweening.Core.Easing;
using DG.Tweening.Core.Surrogates;
using DG.Tweening.Plugins.Core;
using DG.Tweening.Plugins.Options;
using UnityEngine;
#pragma warning disable 1591
namespace DG.Tweening.Plugins
{
public class Vector4SurrogatePlugin : ABSTweenPlugin<Vector4Surrogate, Vector4Surrogate, VectorOptions>
{
public override void Reset(TweenerCore<Vector4Surrogate, Vector4Surrogate, VectorOptions> t) { }
public override void SetFrom(TweenerCore<Vector4Surrogate, Vector4Surrogate, VectorOptions> t, bool isRelative)
{
Vector4Surrogate prevEndVal = t.endValue;
t.endValue = t.getter();
t.startValue = isRelative ? t.endValue + prevEndVal : prevEndVal;
Vector4Surrogate to = t.endValue;
switch (t.plugOptions.axisConstraint) {
case AxisConstraint.X:
to.x = t.startValue.x;
break;
case AxisConstraint.Y:
to.y = t.startValue.y;
break;
case AxisConstraint.Z:
to.z = t.startValue.z;
break;
case AxisConstraint.W:
to.w = t.startValue.w;
break;
default:
to = t.startValue;
break;
}
if (t.plugOptions.snapping) {
to.x = (float)Math.Round(to.x);
to.y = (float)Math.Round(to.y);
to.z = (float)Math.Round(to.z);
to.w = (float)Math.Round(to.w);
}
t.setter(to);
}
public override Vector4Surrogate ConvertToStartValue(TweenerCore<Vector4Surrogate, Vector4Surrogate, VectorOptions> t, Vector4Surrogate value)
{
return value;
}
public override void SetRelativeEndValue(TweenerCore<Vector4Surrogate, Vector4Surrogate, VectorOptions> t)
{
t.endValue += t.startValue;
}
public override void SetChangeValue(TweenerCore<Vector4Surrogate, Vector4Surrogate, VectorOptions> t)
{
switch (t.plugOptions.axisConstraint) {
case AxisConstraint.X:
t.changeValue = new Vector4Surrogate(t.endValue.x - t.startValue.x, 0, 0, 0);
break;
case AxisConstraint.Y:
t.changeValue = new Vector4Surrogate(0, t.endValue.y - t.startValue.y, 0, 0);
break;
case AxisConstraint.Z:
t.changeValue = new Vector4Surrogate(0, 0, t.endValue.z - t.startValue.z, 0);
break;
case AxisConstraint.W:
t.changeValue = new Vector4Surrogate(0, 0, 0, t.endValue.w - t.startValue.w);
break;
default:
t.changeValue = t.endValue - t.startValue;
break;
}
}
public override float GetSpeedBasedDuration(VectorOptions options, float unitsXSecond, Vector4Surrogate changeValue)
{
return changeValue.magnitude / unitsXSecond;
}
public override void EvaluateAndApply(VectorOptions options, Tween t, bool isRelative, DOGetter<Vector4Surrogate> getter, DOSetter<Vector4Surrogate> setter, float elapsed, Vector4Surrogate startValue, Vector4Surrogate changeValue, float duration, bool usingInversePosition)
{
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);
}
float easeVal = EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod);
switch (options.axisConstraint) {
case AxisConstraint.X:
Vector4Surrogate resX = getter();
resX.x = startValue.x + changeValue.x * easeVal;
if (options.snapping) resX.x = (float)Math.Round(resX.x);
setter(resX);
break;
case AxisConstraint.Y:
Vector4Surrogate resY = getter();
resY.y = startValue.y + changeValue.y * easeVal;
if (options.snapping) resY.y = (float)Math.Round(resY.y);
setter(resY);
break;
case AxisConstraint.Z:
Vector4Surrogate resZ = getter();
resZ.z = startValue.z + changeValue.z * easeVal;
if (options.snapping) resZ.z = (float)Math.Round(resZ.z);
setter(resZ);
break;
case AxisConstraint.W:
Vector4Surrogate resW = getter();
resW.w = startValue.w + changeValue.w * easeVal;
if (options.snapping) resW.w = (float)Math.Round(resW.w);
setter(resW);
break;
default:
startValue.x += changeValue.x * easeVal;
startValue.y += changeValue.y * easeVal;
startValue.z += changeValue.z * easeVal;
startValue.w += changeValue.w * easeVal;
if (options.snapping) {
startValue.x = (float)Math.Round(startValue.x);
startValue.y = (float)Math.Round(startValue.y);
startValue.z = (float)Math.Round(startValue.z);
startValue.w = (float)Math.Round(startValue.w);
}
setter(startValue);
break;
}
}
}
}
#endif

View File

@ -75,37 +75,43 @@ namespace DG.Tweening
return false;
}
#else
// WP8.1 fix tries
if (t.tweenPlugin == null) {
Debug.Log("Assigning plugin to ABSTweenPlugin<T1, T2, TPlugOptions> var");
ABSTweenPlugin<T1, T2, TPlugOptions> plug = PluginsManager.GetDefaultPlugin<T1, T2, TPlugOptions>();
if (plug != null) {
Debug.Log(">> Plugin found");
t.tweenPlugin = plug;
Debug.Log(">> Plugin assigned > " + t.tweenPlugin + " (t.tweenPlugin is null: " + (t.tweenPlugin == null) + ")");
if (t.tweenPlugin == null) Debug.Log(">> Plugin assignment failed");
} else Debug.Log(">> Plugin NOT found");
}
if (t.tweenPlugin == null) {
Debug.Log("Assigning plugin to ITweenPlugin var");
ITweenPlugin iplug = PluginsManager.GetDefaultPlugin<T1, T2, TPlugOptions>();
if (iplug != null) {
Debug.Log(">> IPlugin found");
try {
System.Object pObj = (object)iplug;
t.tweenPlugin = (ABSTweenPlugin<T1, T2, TPlugOptions>)pObj;
} catch (Exception e) {
Debug.Log(">> Error while assigning IPlugin > " + e.Message);
}
Debug.Log(">> IPlugin assigned > " + t.tweenPlugin + " (t.tweenPlugin is null: " + (t.tweenPlugin == null) + ")");
if (t.tweenPlugin == null) Debug.Log(">> IPlugin assignment failed");
} else Debug.Log(">> IPlugin NOT found");
}
if (t.tweenPlugin == null) t.tweenPlugin = PluginsManager.GetDefaultPlugin<T1, T2, TPlugOptions>();
if (t.tweenPlugin == null) {
// No suitable plugin found. Kill
Debugger.LogError("No suitable plugin found for this type");
return false;
}
// WP8.1 fix tries
// if (t.tweenPlugin == null) {
// Debug.Log("Assigning plugin to ABSTweenPlugin<T1, T2, TPlugOptions> var");
// ABSTweenPlugin<T1, T2, TPlugOptions> plug = PluginsManager.GetDefaultPlugin<T1, T2, TPlugOptions>();
// if (plug != null) {
// Debug.Log(">> Plugin found");
// t.tweenPlugin = plug;
// Debug.Log(">> Plugin assigned > " + t.tweenPlugin + " (t.tweenPlugin is null: " + (t.tweenPlugin == null) + ")");
// if (t.tweenPlugin == null) Debug.Log(">> Plugin assignment failed");
// } else Debug.Log(">> Plugin NOT found");
// }
// if (t.tweenPlugin == null) {
// Debug.Log("Assigning plugin to ITweenPlugin var");
// ITweenPlugin iplug = PluginsManager.GetDefaultPlugin<T1, T2, TPlugOptions>();
// if (iplug != null) {
// Debug.Log(">> IPlugin found");
// try {
// System.Object pObj = (object)iplug;
// t.tweenPlugin = (ABSTweenPlugin<T1, T2, TPlugOptions>)pObj;
// } catch (Exception e) {
// Debug.Log(">> Error while assigning IPlugin > " + e.Message);
// }
// Debug.Log(">> IPlugin assigned > " + t.tweenPlugin + " (t.tweenPlugin is null: " + (t.tweenPlugin == null) + ")");
// if (t.tweenPlugin == null) Debug.Log(">> IPlugin assignment failed");
// } else Debug.Log(">> IPlugin NOT found");
// }
// if (t.tweenPlugin == null) {
// // No suitable plugin found. Kill
// Debugger.LogError("No suitable plugin found for this type");
// return false;
// }
// WP8.1 fix tries END
#endif
}