Search Issue Tracker

Third Party Issue

Votes

0

Found in

2022.3.58f1

6000.0.38f1

6000.1.0b6

6000.2.0a3

Issue ID

UUM-97497

Regression

No

[sw-unity-6-1] Code is executed twice in a Coroutine when "WaitUntil(() => Input.GetKeyDown())" is used with "while(true)"

-

How to reproduce:
1. Open the "ReportingBugs.zip" project
2. Open the "WaitUntilScene" Scene
3. Enter Play Mode
4. Press the "F" key on your keyboard
5. Observe the Hierarchy

Expected result: One "Cube (Clone)" GameObject is instantiated
Actual result: Two "Cube (Clone)" GameObjects are instantiated

Reproducible in: 2022.3.58f1, 6000.0.38f1, 6000.1.0b6, 6000.2.0a3

Reproduced on: Windows 11 Pro (23H2)
Not reproduced on: No other environment tested

  1. Resolution Note:

    The user code is actually to blame here as the second WaitUntil call happens within the same frame as the one that got unblocked by the key press. Luckilly it seems WaitUntil today always wait for at least one frame so it does not end up with an infinite loop, but that is what I expected by looking at the code: within the same frame, Input.GetKeyDown(KeyCode.F) will always return true.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.