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:
balance += totalPayment;
UpdateUI();
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:
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");