Hello,
I have a script with an IEnumerator that counts up the players score from 0 to the current score. Here is my script snips:
WaitForSeconds counterCountTime = new WaitForSeconds(0.7f);
IEnumerator Counter(int count)
{
for (int i = 0; i < count; i++)
{
score++;
return (counterCountTime / count);
}
}
I’m defining WaitForSeconds as a variable to avoid GC and use a return, but I received an error saying:
Operator ’ / ’ cannot be applied to operands of type ‘UnityEngine.WaitForSeconds’ and ‘int’
If I use the following then it will add to GC and I want to avoid it.
yield return new WaitForSeconds(0.7f / count);