#What is an IEnumerator?

1 messages · Page 1 of 1 (latest)

gilded phoenix
#

it would be nice if someone could do an "Explain like im 5" of whta an IEnumerator is/is used for

lost stream
#

In plain C#, IEnumerator instances are (mainly) used by foreach loops to iterate over collections.
Inside Unity however, they have yet another purpose: They can be used as coroutines. You can think of those like methods that can be paused, or more generally, executed over the course of multiple frames.
Yasahiro has a blog where he explains how coroutines work: https://blog.oliverbooth.dev/2021/04/27/how-do-unitys-coroutines-actually-work/.

gilded phoenix
#

Thank you 👍

#

would you be able to maybe solve an unrelated question for me right here as i have to wait to make a new post

lost stream
#

I can't tell whether I'd be able to solve a problem, without knowing said problem.
In either case though, I strongly urge you to wait and make a separate post. Perhaps use the time to read the blog I linked and get familiar with coroutines, as they can be an incredibly handy tool.

gilded phoenix