Last active
October 12, 2020 14:07
-
-
Save Awais6/b15e6e0d8162301d15c401629e3170bd to your computer and use it in GitHub Desktop.
UpdateCoinsTest Animation slowely increase coins in c# unity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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