1
\$\begingroup\$

What is the "right" way to dispose of an Ienumerator coroutine after it has completed?

\$\endgroup\$
1

1 Answer 1

1
\$\begingroup\$

Do nothing.

You let the IEnumerator method run to the end and then let the garbage collector take care of it automatically.

C# is a garbage-collected language. There are very few edge cases where you need to dispose things manually, and this isn't one of them.

\$\endgroup\$
2
  • \$\begingroup\$ Well, when you do rendertexture or texture read/write you should dispose of the texture - so i wonder if ienumerators are also required to be manually disposed of? \$\endgroup\$
    – ina
    Dec 6, 2021 at 9:20
  • \$\begingroup\$ @ina No, coroutines do not need to be disposed in Unity. Render textures are one of the few edge-cases I mentioned above where a manual release is required. \$\endgroup\$
    – Philipp
    Dec 6, 2021 at 10:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .