0
0
Unityframework~10 mins

Coroutine basics (IEnumerator) in Unity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start a coroutine named MyCoroutine.

Unity
StartCoroutine([1]);
Drag options to blanks, or click blank then click option'
AIEnumerator
BMyCoroutine
CMyCoroutine()
DStartCoroutine()
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting parentheses and writing just the method name.
Trying to call StartCoroutine inside itself.
2fill in blank
medium

Complete the code to make the coroutine wait for 2 seconds.

Unity
yield return [1];
Drag options to blanks, or click blank then click option'
Anew WaitForSeconds(2)
BWaitForSeconds(2)
C2
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Not using 'new' keyword before WaitForSeconds.
Yielding just a number instead of a WaitForSeconds object.
3fill in blank
hard

Fix the error in the coroutine declaration to make it valid.

Unity
private [1] MyCoroutine() {
    yield return null;
}
Drag options to blanks, or click blank then click option'
Avoid
BIEnumerator
Cint
DCoroutine
Attempts:
3 left
💡 Hint
Common Mistakes
Using void instead of IEnumerator.
Using Coroutine as return type which is incorrect for method signature.
4fill in blank
hard

Fill both blanks to create a coroutine that waits 3 seconds and then prints a message.

Unity
private IEnumerator WaitAndPrint() {
    yield return [1];
    Debug.[2]("Waited 3 seconds");
}
Drag options to blanks, or click blank then click option'
Anew WaitForSeconds(3)
BLog
CPrint
DWaitForSeconds(3)
Attempts:
3 left
💡 Hint
Common Mistakes
Using WaitForSeconds(3) without 'new'.
Using Debug.Print instead of Debug.Log.
5fill in blank
hard

Fill all three blanks to create a coroutine that waits 1 second, then waits 2 seconds, and finally prints 'Done'.

Unity
private IEnumerator DoubleWait() {
    yield return [1];
    yield return [2];
    Debug.[3]("Done");
}
Drag options to blanks, or click blank then click option'
Anew WaitForSeconds(1)
Bnew WaitForSeconds(2)
CLog
DPrint
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the wait times or missing 'new' keyword.
Using Debug.Print instead of Debug.Log.