0
0
Unityframework~10 mins

WaitForSeconds and WaitForEndOfFrame 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 wait for 2 seconds before printing a message.

Unity
IEnumerator WaitAndPrint() {
    yield return new [1](2f);
    Debug.Log("Waited 2 seconds");
}
Drag options to blanks, or click blank then click option'
AWaitForEndOfFrame
BWaitForFixedUpdate
CWaitUntil
DWaitForSeconds
Attempts:
3 left
💡 Hint
Common Mistakes
Using WaitForEndOfFrame instead of WaitForSeconds.
2fill in blank
medium

Complete the code to wait until the end of the current frame before continuing.

Unity
IEnumerator WaitForFrameEnd() {
    yield return new [1]();
    Debug.Log("Frame ended");
}
Drag options to blanks, or click blank then click option'
AWaitForEndOfFrame
BWaitForSeconds
CWaitForFixedUpdate
DWaitUntil
Attempts:
3 left
💡 Hint
Common Mistakes
Using WaitForSeconds with no time parameter.
3fill in blank
hard

Fix the error in the coroutine to wait for 3 seconds before printing.

Unity
IEnumerator WaitThreeSeconds() {
    yield return new [1](3f);
    Debug.Log("3 seconds passed");
}
Drag options to blanks, or click blank then click option'
AWaitForSeconds
BWaitForEndOfFrame
CWaitForFixedUpdate
DWaitUntil
Attempts:
3 left
💡 Hint
Common Mistakes
Using WaitForEndOfFrame which takes no parameters.
4fill in blank
hard

Fill both blanks to create a coroutine that waits for the end of frame, then waits 1 second.

Unity
IEnumerator WaitFrameThenSecond() {
    yield return new [1]();
    yield return new [2](1f);
    Debug.Log("Waited frame end and 1 second");
}
Drag options to blanks, or click blank then click option'
AWaitForEndOfFrame
BWaitForSeconds
CWaitForFixedUpdate
DWaitUntil
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of waits or using wrong classes.
5fill in blank
hard

Fill all three blanks to create a coroutine that waits 0.5 seconds, then waits for frame end, then waits 2 seconds.

Unity
IEnumerator ComplexWait() {
    yield return new [1](0.5f);
    yield return new [2]();
    yield return new [3](2f);
    Debug.Log("Completed complex wait");
}
Drag options to blanks, or click blank then click option'
AWaitForSeconds
BWaitForEndOfFrame
CWaitForFixedUpdate
DWaitUntil
Attempts:
3 left
💡 Hint
Common Mistakes
Using WaitForFixedUpdate or WaitUntil incorrectly.