Skip to main content
added 104 characters in body
Source Link
Nikaas
  • 931
  • 7
  • 12

You can think of IEnumerator as a counter/sequence. It has an internal state to what position it reached. In the case of unity coroutines it is a sequence of waiting times. When you run it once you gone through the full sequence and it is at its end. I have not tested it but likely you can call Reset() on the enumerator to runbefore passing it again to StartCoroutine. BTW this makes me think that you should be careful to not run the same enumerator in parallel with itself. In the case of delegates a new enumerator is created each time you start a coroutine (or maybe even some unity magic to avoid the garbage).

You can think of IEnumerator as a counter/sequence. It has an internal state to what position it reached. In the case of unity coroutines it is a sequence of waiting times. I have not tested it but likely you can call Reset() on the enumerator to run it again. BTW this makes me think that you should be careful to not run the same enumerator in parallel with itself. In the case of delegates a new enumerator is created each time you start a coroutine (or maybe even some unity magic to avoid the garbage).

You can think of IEnumerator as a counter/sequence. It has an internal state to what position it reached. In the case of unity coroutines it is a sequence of waiting times. When you run it once you gone through the full sequence and it is at its end. I have not tested it but likely you can call Reset() on the enumerator before passing it again to StartCoroutine. BTW this makes me think that you should be careful to not run the same enumerator in parallel with itself. In the case of delegates a new enumerator is created each time you start a coroutine (or maybe even some unity magic to avoid the garbage).

Source Link
Nikaas
  • 931
  • 7
  • 12

You can think of IEnumerator as a counter/sequence. It has an internal state to what position it reached. In the case of unity coroutines it is a sequence of waiting times. I have not tested it but likely you can call Reset() on the enumerator to run it again. BTW this makes me think that you should be careful to not run the same enumerator in parallel with itself. In the case of delegates a new enumerator is created each time you start a coroutine (or maybe even some unity magic to avoid the garbage).