Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - DarkSlash

Pages: [1]
DOTween & DOTween Pro / Can't tween float
« on: September 20, 2015, 12:23:03 AM »
I have a float variable called balance and I show it in a 2d Toolkit TextMesh. Right now, Im doing something like this to change it:
Code: [Select]
balance += totalPayment;

But I don't want to change the value from A to B. Let's say balance = 50 and totalPayment = 150, I want to increase it 50,51,52,53 (or something like that) until 200 (balance + totalPayment). So the closest I got is this:

Code: [Select]
float to = balance + totalPayment;
DOTween.To(() => balance, x => balance = x, to, 2).OnComplete(UpdateUI);

Nevertheless, this doesn't work as expected. It doesn't do what I need, it just wait 2 seconds and then change the value of balance to balance+totalPayment. What I'm doing wrong?

EDIT: UpdateUI just take does this: txtBalance.text = balance.ToString("F2"); 

Pages: [1]