0
0
Unityframework~10 mins

Coroutine chaining 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'
A"MyCoroutine"
BMyCoroutine()
CMyCoroutine
DStartMyCoroutine()
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the coroutine method name as a string without parentheses.
Passing the method name without parentheses.
2fill in blank
medium

Complete the code to wait for 2 seconds inside a coroutine.

Unity
yield return [1];
Drag options to blanks, or click blank then click option'
Anew WaitForSeconds(2)
BWaitForSeconds(2f)
Cnew WaitForSeconds(2f)
DWaitForSeconds(2)
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the new keyword.
Not using parentheses around the time value.
3fill in blank
hard

Fix the error in the coroutine chaining code to wait for SecondCoroutine to finish before continuing.

Unity
yield return [1](SecondCoroutine());
Drag options to blanks, or click blank then click option'
AInvoke
BWaitForSeconds
CStartCoroutine
DStart
Attempts:
3 left
💡 Hint
Common Mistakes
Using WaitForSeconds instead of StartCoroutine.
Calling Invoke which does not return IEnumerator.
4fill in blank
hard

Fill both blanks to chain two coroutines so that FirstCoroutine waits for SecondCoroutine before continuing.

Unity
IEnumerator FirstCoroutine() {
    yield return [1](SecondCoroutine());
    Debug.Log([2]);
}
Drag options to blanks, or click blank then click option'
AStartCoroutine
B"Second coroutine finished"
C"Coroutine done"
DDebug.Log
Attempts:
3 left
💡 Hint
Common Mistakes
Not using StartCoroutine to wait.
Logging the wrong message.
5fill in blank
hard

Fill all three blanks to create a coroutine that chains three coroutines and logs messages after each finishes.

Unity
IEnumerator ChainCoroutines() {
    yield return [1](CoroutineOne());
    Debug.Log([2]);
    yield return [3](CoroutineTwo());
    Debug.Log("All coroutines done");
}
Drag options to blanks, or click blank then click option'
AStartCoroutine
B"Coroutine One finished"
D"Coroutine Two finished"
Attempts:
3 left
💡 Hint
Common Mistakes
Not using StartCoroutine for both coroutines.
Mixing up the log messages.