Hi everyone
I want to make some kind of presentation with Unity, this project includes numerical statistics so I want to make them look alive with the growing “animation”. My problem is that even with a Coroutine this number is shown instantly.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class grownumber : MonoBehaviour {
public int limit;
private int counter;
private Text text_n;
// Use this for initialization
void Start () {
text_n = GameObject.Find ("number").GetComponent<Text>();
counter = 0;
limit = 60000;
}
// Update is called once per frame
void Update () {
}
void grow(){
for(int i=0;i<limit;i++){
StartCoroutine ("count");
}
}
void OnTriggerEnter (Collider other){
if (other.tag == "Player") {
print ("collider");
grow ();
}
}
IEnumerator count(){
yield return new WaitForSeconds (0.5f);
counter+=1;
text_n.text = ""+counter+"";
}
}