Hello, I have a ‘for’ loop in my coroutine who cause a Unity freezing. I’ve tried to fix it, but I don’t understand… Anybody has an idea why the loop provokes a freeze?
Thanks !
The coroutine :
public static IEnumerator ScoreCountTo(int score, int target)
{
Debug.Log("Score Count ");
int duration = 3;
int start = score;
float progress = 0f;
string str = LanguageManager.Instance.readValue("txt_score");
updateField(0, str + score);
for (float timer = 0; timer < duration; timer += Time.deltaTime )
{
Debug.Log("Timer " + timer + " Time.deltaTime " + Time.deltaTime);
// progress = timer / duration;
//score = (int)Mathf.Lerp(start, target, progress);
//updateField(0, str + score);
yield return null;
}
updateField(0, str + target);
MainSingleton.Instance.stopTime();
}
Last result before the freeze :