Skip to content

Instantly share code, notes, and snippets.

@Awais6
Last active October 12, 2020 14:07
Show Gist options
  • Save Awais6/b15e6e0d8162301d15c401629e3170bd to your computer and use it in GitHub Desktop.
Save Awais6/b15e6e0d8162301d15c401629e3170bd to your computer and use it in GitHub Desktop.
UpdateCoinsTest Animation slowely increase coins in c# unity.
private IEnumerator UpdateCoinsAmount (int prevCoins, int newCoins)
{
// Animation for increasing and decreasing of coins amount
const float seconds = 0.5f;
float elapsedTime = 0;
while (elapsedTime < seconds) {
CurrentCoinsText.text = Mathf.Floor(Mathf.Lerp (prevCoins, newCoins, (elapsedTime / seconds))).ToString();
elapsedTime += Time.deltaTime;
yield return new WaitForEndOfFrame ();
}
CurrentCoinsText.text = newCoins.ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment