A. AsyncOperation.progress should be multiplied by 100
B. The while loop condition should be asyncLoad.isDone == true
C. The coroutine never yields control to the main thread
D. Using WaitForSeconds delays UI updates unnecessarily
Solution
Step 1: Check yield statement impact
Using yield return new WaitForSeconds(1) pauses the coroutine for 1 second each loop, causing slow UI updates.
Step 2: Suggest better yield usage
Yielding null (yield return null) updates every frame, making progress bar smoother and more responsive.
Final Answer:
Using WaitForSeconds delays UI updates unnecessarily -> Option D
Quick Check:
WaitForSeconds slows progress updates = B [OK]
Hint: Use yield return null for smooth frame-by-frame updates [OK]
Common Mistakes:
Confusing progress value scale
Changing loop condition incorrectly
Not yielding at all causing freeze
5. You want to create a loading screen that shows a progress bar and a "Loading..." text that updates smoothly while loading a scene asynchronously. Which approach correctly combines coroutines and UI updates?
hard
A. Load the scene synchronously and update UI after loading finishes
B. Start a coroutine that updates progressBar.fillAmount with asyncLoad.progress every frame and updates loadingText with percentage until asyncLoad.isDone is true
C. Start a coroutine that waits 5 seconds then sets progressBar.fillAmount to 1 and loadingText to "Done"
D. Use Update() method to check asyncLoad.progress and update UI, no coroutine needed
Solution
Step 1: Understand asynchronous loading with UI updates
Using a coroutine to check asyncLoad.progress each frame allows smooth progress bar and text updates during loading.
Step 2: Evaluate options for UI responsiveness
Start a coroutine that updates progressBar.fillAmount with asyncLoad.progress every frame and updates loadingText with percentage until asyncLoad.isDone is true correctly updates UI every frame until loading completes; other options either block UI or do not update smoothly.
Final Answer:
Start a coroutine that updates progressBar.fillAmount with asyncLoad.progress every frame and updates loadingText with percentage until asyncLoad.isDone is true -> Option B