0
0
Unityframework~5 mins

Stopping coroutines in Unity - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AStopAllCoroutines()
BStopCoroutine()
CEndCoroutine()
DCancelCoroutine()
How do you stop a coroutine if you only know its method name?
AStopCoroutine(coroutineVariable)
BStopCoroutine(MethodName())
CStopCoroutine("MethodName")
DStopAllCoroutines()
What must you save when starting a coroutine to stop it later by reference?
ACoroutine variable from StartCoroutine()
BMethod name string
CIEnumerator variable
DGameObject reference
What happens if you call StopCoroutine on a coroutine that is not running?
AThrows an exception
BNothing happens, no error
CRestarts the coroutine
DPauses the coroutine
Which of these is NOT a valid way to stop a coroutine?
AStopCoroutine(coroutineVariable)
BStopCoroutine("MethodName")
CStopCoroutine(IEnumerator variable)
DStopCoroutine(GameObject)
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.