Demigiant / dotween

A Unity C# animation engine. HOTween v2
http://dotween.demigiant.com
Other
2.3k stars 346 forks source link

DoTween.To() causes stack underflow when used to decrease a ulong value. #631

Open emredesu opened 1 year ago

emredesu commented 1 year ago

Hey! I've been having a blast developing my game with DoTween. I just came across an issue that I believe is caused by internal DoTween code. When increasing an ulong value to another ulong value, it works without a problem. However, when I try to decrease an ulong value to another ulong value, the value goes up to the maximum value of an ulong, which I believe is caused by a stack underflow. It is extremely easy to replicate, just paste this code anywhere:

ulong testVar1 = 10;
ulong testVar2 = 5;

DOTween.To(() => testVar1, val => testVar1 = val, testVar2, 5).OnUpdate(() => Debug.Log(testVar1));

and you'll come across the issue I'm having. The stack trace in the Unity console is as follows:

DOTWEEN ► Target or field is missing/null (UInt64 ToUInt64(System.Decimal)) ► Value was either too large or too small for a UInt64.

  at System.Decimal.ToUInt64 (System.Decimal d) [0x00025] in <c2a97e0383e8404c9fc0ae19d58f57f1>:0 
  at System.Decimal.op_Explicit (System.Decimal value) [0x00000] in <c2a97e0383e8404c9fc0ae19d58f57f1>:0 
  at DG.Tweening.Plugins.UlongPlugin.EvaluateAndApply (DG.Tweening.Plugins.Options.NoOptions options, DG.Tweening.Tween t, System.Boolean isRelative, DG.Tweening.Core.DOGetter`1[T] getter, DG.Tweening.Core.DOSetter`1[T] setter, System.Single elapsed, System.UInt64 startValue, System.UInt64 changeValue, System.Single duration, System.Boolean usingInversePosition, System.Int32 newCompletedSteps, DG.Tweening.Core.Enums.UpdateNotice updateNotice) [0x00084] in D:\DG\_Develop\__UNITY3_CLASSES\_Holoville\__DOTween\_DOTween.Assembly\DOTween\Plugins\UlongPlugin.cs:71 
  at DG.Tweening.Core.TweenerCore`3[T1,T2,TPlugOptions].ApplyTween (System.Single prevPosition, System.Int32 prevCompletedLoops, System.Int32 newCompletedSteps, System.Boolean useInversePosition, DG.Tweening.Core.Enums.UpdateMode updateMode, DG.Tweening.Core.Enums.UpdateNotice updateNotice) [0x00030] in D:\DG\_Develop\__UNITY3_CLASSES\_Holoville\__DOTween\_DOTween.Assembly\DOTween\Core\TweenerCore.cs:261 

UnityEngine.Debug:LogWarning (object)
DG.Tweening.Core.Debugger:LogSafeModeCapturedError (object,DG.Tweening.Tween) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/Debugger.cs:61)
DG.Tweening.Core.TweenerCore`3<ulong, ulong, DG.Tweening.Plugins.Options.NoOptions>:ApplyTween (single,int,int,bool,DG.Tweening.Core.Enums.UpdateMode,DG.Tweening.Core.Enums.UpdateNotice) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenerCore.cs:265)
DG.Tweening.Tween:DoGoto (DG.Tweening.Tween,single,int,DG.Tweening.Core.Enums.UpdateMode) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Tween.cs:266)
DG.Tweening.Core.TweenManager:Update (DG.Tweening.Tween,single,single,bool) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:569)
DG.Tweening.Core.TweenManager:Update (DG.Tweening.UpdateType,single,single) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:417)
DG.Tweening.Core.DOTweenComponent:Update () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:75)

Thanks and good luck!