Re-visiting Unity after a break, I encountered an annoying lag in play mode even when moving simple 2D shapes:
- It went away during full builds, but this isn’t much of a solution while you’re hacking away on White Square on Blue Background Ultimate Party Edition III and craving a rapid feedback loop.
- Frame rate in game mode stats remained stable and high even during jitter.
- Other users report the same issue on macOS (example 1, example 2) across various versions of Unity, but there’s no published solution.
For me it was a display refresh rate issue. To fix it:
- Exit play mode.
- Visit Unity → Preferences.
- Change Interaction Mode from Default to Custom, but note the value next to Monitor Refresh Rate in the drop-down (in my case 16 ms).
- Set the Frame Throttling (milliseconds) to a number lower than your monitor refresh rate. 12 worked well for me on a MacBook Pro 16, but feel free to experiment. If you go too low or too high you may see stuttering again.
Ta-da! No more stutter in play mode and no Unity restart required:
The interaction mode setting is mentioned in Unity docs with this note:
In Play mode, Unity ignores any throttling that you apply using this preference. The editor updates as fast as possible unless you enable the VSync option in the Game view, or set Application.targetFrameRate to a value other than –1.
I didn’t find that to be the case. I hadn’t altered
Application.targetFrameRate or enabled VSync and the differences between frame throttling of 2 (resulting in lag) and frame throttling of 12 (works great) or 20 (lag again) are noticeable.