Complete the code to start a coroutine that waits for 2 seconds.
StartCoroutine([1]()); IEnumerator WaitAndPrint() { yield return new WaitForSeconds(2); Debug.Log("Waited 2 seconds"); }
The coroutine method name WaitAndPrint is passed to StartCoroutine to begin the timed wait.
Complete the code to pause execution inside a coroutine for 3 seconds.
IEnumerator PauseCoroutine() {
yield return new [1](3);
Debug.Log("Paused for 3 seconds");
}new WaitForSeconds(3) pauses the coroutine for 3 seconds before continuing.
Fix the error in the coroutine that should wait 1 second before printing.
IEnumerator PrintAfterDelay() {
yield return new [1](1);
Debug.Log("Printed after 1 second");
}The correct Unity class to wait is WaitForSeconds. The others are invalid.
Fill both blanks to create a coroutine that waits 5 seconds and then prints a message.
IEnumerator DelayedMessage() {
yield return new [1](5);
Debug.Log([2]);
}The coroutine waits 5 seconds using WaitForSeconds and then prints the message Hello after delay.
Fill all three blanks to create a coroutine that waits 2 seconds, then waits until a condition is true, and finally prints a message.
IEnumerator WaitForCondition() {
yield return new [1](2);
yield return new [2](() => [3]);
Debug.Log("Condition met!");
}The coroutine first waits 2 seconds with WaitForSeconds, then waits until the boolean isReady is true using WaitUntil.