Search Issue Tracker
By Design
Votes
0
Found in
2023.1.0b20
2023.2.0a18
Issue ID
UUM-37783
Regression
No
NextFrameAsync does not return when Time.timeScale is set to zero the second time
How to reproduce:
1. Open the “AwaitableTimeReproduction.zip“ project
2. Open the “SampleScene“
3. Enter Play mode
4. Click the "Start" button
5. Click the "Resume" button
6. Click the "Pause" button
Expected result: The counter in front of the “Frames“ text stops counting frames
Actual result: The counter in front of the “Frames“ text continues to count frames
Reproducible with: 2023.1.0b20, 2023.2.0a18
Could not test with: 2021.3.27f1, 2022.3.1f1 (Awaitable functions are not available)
Reproducible on: Windows 10, Windows 11
Note: Reproducible in Player.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Crash on RaiseException when opening a specific project
- DownloadHandlerScript.CompleteContent is called twice when building for WebGL
- Scene view has Y coordinates of the Screen Position node flipped when some of the URP features are disabled
- Volumetric fog shader variants are missing from build when "Strict Shader Variant Matching" is disabled
- Unnecessary modifications clutter the Scene when using a RectTransform driven by a LayoutGroup in a Prefab
Resolution Note:
Unity's framerate is not affected by Time.timeScale, therefore, awaiting for next frame is not affected by it too. Even if timeScale is 0 unity will still render game frames thus frame counting loop will count new frames.
However, things work a bit differently with physics updates. Not only do they happen on set time intervals but are also affected by timeScale property.
So this case is not an engine bug and the intention of users' code can be achieved in multiple ways:
* If awaitable frame counter is needed, we would suggest introducing a variable that's representing frame counters state(paused or not paused) and counting frames only when frame counter is not paused.
* Otherwise, if one needs to rely on timeScale property to stop counting frames or time, we suggest adapting counting method to await for `Awaitable.FixedUpdateAsync`.