Recall & Review
beginner
What is a coroutine in Unity?
A coroutine is a special function that can pause execution and resume later, allowing you to run code over multiple frames without blocking the main game loop.
Click to reveal answer
beginner
How do you start a coroutine in Unity?
You start a coroutine by calling
StartCoroutine(MethodName()) inside a MonoBehaviour script.Click to reveal answer
intermediate
What method is used to stop a running coroutine by its name?
You can stop a coroutine by calling
StopCoroutine("MethodName"), passing the coroutine's method name as a string.Click to reveal answer
intermediate
How can you stop a coroutine using a Coroutine variable?
When you start a coroutine, you can save its reference like
Coroutine myCoroutine = StartCoroutine(MethodName()). Then stop it by calling StopCoroutine(myCoroutine).Click to reveal answer
intermediate
What happens if you call
StopAllCoroutines() in a MonoBehaviour?It stops all coroutines running on that MonoBehaviour immediately, cancelling all paused or running coroutine executions.
Click to reveal answer
Which method stops all coroutines running on a MonoBehaviour?
✗ Incorrect
StopAllCoroutines() stops every coroutine running on the MonoBehaviour. The others are incorrect or do not exist.
How do you stop a coroutine if you only know its method name?
✗ Incorrect
Use the method name as a string in StopCoroutine to stop it by name.
What must you save when starting a coroutine to stop it later by reference?
✗ Incorrect
Saving the Coroutine returned by StartCoroutine() lets you stop it later by passing that variable.
What happens if you call StopCoroutine on a coroutine that is not running?
✗ Incorrect
Calling StopCoroutine on a non-running coroutine does nothing and does not cause errors.
Which of these is NOT a valid way to stop a coroutine?
✗ Incorrect
You cannot stop a coroutine by passing a GameObject. The others are valid ways.
Explain how to stop a coroutine in Unity using both the method name and Coroutine variable approaches.
Think about the two common ways Unity lets you stop coroutines.
You got /3 concepts.
Describe what StopAllCoroutines does and when you might want to use it.
Consider a situation where many coroutines run and you want to stop them all quickly.
You got /3 concepts.