Open 0kk470 opened 5 years ago
Ahoy!
That should actually work with string tweens. Is it possible that you didn't set your tween to avoid auto-kill-on-completion (by chaining a SetAutokill(false)
), and thus it's killed and becomes un-reusable?
Ahoy!
That should actually work with string tweens. Is it possible that you didn't set your tween to avoid auto-kill-on-completion (by chaining a
SetAutokill(false)
), and thus it's killed and becomes un-reusable?
thx for replying. The autoKill is also set to 'false'. Actually,the tween can be reused but its endvalue will never change when restarted. Here's my code
if self.twn then
self.twn:ChangeValues(fBeginValue, fEndValue)
self.twn:Restart()
else
self.twn = CS.DG.Tweening.DOTween.To(function(iCurValue) numberText.text = math.floor(iCurValue) end,fBeginValue,fEndValue,fDuration)
self.twn:SetAutoKill(false)
end
Oh, wait, I thought your previous code was a stub, but I see it's really like that... what coding language are you using? :B
Oh, wait, I thought your previous code was a stub, but I see it's really like that... what coding language are you using? :B
well, it's Lua. I used a solution called xlua so that I can call C# function in Lua VM
I have the same problem when trying to change values on a running DOTween.To(). I haven't quite been able to isolate when it does or doesn't work. As you can see in the example I have a version that doesn't work and one that does. Unfortunately this doesn't solve the problem for my actual usecase.
using System.Collections;
using DG.Tweening;
using UnityEngine;
public class TweenTest : MonoBehaviour
{
public float TweenMe;
public float IncreaseValue = 10f;
public float Duration = 1.5f;
public float PerSeconds = 1f;
private Tweener _tween;
IEnumerator Start()
{
// Works, keeps tweening higher and higher smoothly:
// _tween = DOTween.To(() => TweenMe, v => TweenMe = v, IncreaseValue, Duration).SetAutoKill(false);
// Doesn't work, jumps from value to value instantly:
_tween = DOTween.To(() => TweenMe, v => TweenMe = v, 0f, 0f).SetAutoKill(false);
while (true)
{
yield return new WaitForSeconds(PerSeconds);
_tween.ChangeValues(TweenMe, TweenMe + IncreaseValue, Duration);
}
}
}
Hi there, I have Implemented a Number-Rolling Tweener for player's score increasing and I want to reuse it with different values every time the score is up. I use ChangeValues , But it seems not to work.
self.twn = DOTween.To( function(iCurValue) numberText.text = math.floor(iCurValue) end, fBeginValue, fEndValue, fDuration)
self.twn:ChangeValues(...)
I read the documentation and found a note told that this works on regular tweens, not on ones that do more than just animate one value from one point to another. Is there any other ways to change the tweener's values and reuse it?