Windows 10 Pro Any version of 2021.3 (currently using 2021.3.33f1)
By default, the Editor automatically detects changes to assets and reimports them. When a script changes, this triggers a recompile of the scripts.
I have two monitors and work with Visual Studio on one monitor and the Unity Editor on the other monitor.
It seems like the Editor is only supposed to refresh when it is focused; for example, normally if I am working in Visual Studio and save periodically, the Editor doesn’t auto-refresh until I click on it again.
However, sometimes the Editor decides that it wants to auto-refresh immediately as soon as any script changes, even when Visual Studio is focused and the Editor isn’t.
Yesterday, I decided to try disabling auto-refresh, and this seemed to fix the issue. However, today the Editor is back to immediately auto-refreshing as soon as any script changes, even when the Editor isn’t in focus. I’ve toggled the auto-refresh setting (Preferences > Asset Pipeline > Auto Refresh) on and off several times, but it doesn’t seem like that has any effect.
I did find a Reddit thread where a user reported that the fix is to manually edit a value in the Windows registry: Reddit - Dive into anything I will try that out, but obviously it’s something that we shouldn’t have to do.
Ah, that does sound like it would cause the problem - though it’s strange that the behavior is inconsistent, with the Editor sometimes only auto-refreshing while in focus. Thanks!
Unity Staff: The tooltip for the “Auto Refresh” setting in Unity should probably say “IDEs such as Visual Studio may tell Unity to refresh independently of this setting”.
The description for the “Refresh Unity’s AssetDatabase on save” setting in VS says it requires the Editor to be configured to run in the background, though as far as I know there’s no “run in background” setting for the Editor itself, only for the Player.
I’ll try turning this setting off in Visual Studio.
Incredibly, I’ve now turned off the setting in both apps… and yet, for some reason, randomly it will auto-refresh. This never happened when using VS Code, so maybe it’s still something specific to Visual Studio.