When to use IEnumerator ?
I originally posted this question in the following thread, but figured it may be better suited as it's own question.
When would you use an IEnumerator instead of a normal function (e.g. public void)?
If you don't need to use the WaitForSeconds, is there any point in using an IEnumerator?
Why do all WWW examples use IEnumerator? Are they a necessity?
Answer by Morgenstern_1 · Jun 14, 2016 at 03:28 PM
IEnumerator is used when you want to create a function that can return control to the main process then carry on where it left off when control returns to it. So if you want something that can run in the background, and not freeze the rest of your code while it runs you'd use IEnumerator.
You can use a variety of yields other than WaitForSeconds e.g. WaitForEndOfFrame. You'll get a compiler error if you don't use any kind of yield.
They likely use it so that the code doesn't hang while loading a resource. You wouldn't want your browser to freeze every time you typed in a web address until that page was loaded, same kind of thing :)
Hope that helped!