Search Unity

Bug Editor auto-refreshes when auto-refresh is disabled

Discussion in 'Editor & General Support' started by OneManEscapePlan, Jan 18, 2024.

  1. OneManEscapePlan

    OneManEscapePlan

    Joined:
    Oct 14, 2015
    Posts:
    222
    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: https://www.reddit.com/r/Unity3D/comments/u46br0/disabling_autorefresh_not_working/?rdt=59239 I will try that out, but obviously it's something that we shouldn't have to do.
     
  2. CodeRonnie

    CodeRonnie

    Joined:
    Oct 2, 2015
    Posts:
    531
    Make sure this option is set to false in your Visual Studio options, and see if the behavior continues.
    RefreshOnSave.png
     
    OneManEscapePlan likes this.
  3. OneManEscapePlan

    OneManEscapePlan

    Joined:
    Oct 14, 2015
    Posts:
    222
    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.
     
    CodeRonnie likes this.
  4. CodeRonnie

    CodeRonnie

    Joined:
    Oct 2, 2015
    Posts:
    531
    I agree that it's confusing for there to be more than one setting, across two different apps, that can affect the refresh behavior.
     
  5. MaxLohMusic

    MaxLohMusic

    Joined:
    Jan 17, 2022
    Posts:
    67
    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.