This problem has already been described in several places:
I just want to make it an official feature request. To summarize, we have two options of how to recompile scripts, and neither are really acceptable:
- With auto-refresh on, every time we switch from the code editor to the Unity editor to check something we need to wait for the scripts to needlessly recompile before we can check it.
- With auto-refresh off, we need to remember to manually recompile the scripts every time we press play. If we donāt, things can get messy as we struggle to understand why our code isnāt working because thereās no indication that the scripts are out-of-date.
I believe option 2 is better because human error can be corrected, but the problem with option 1 isnāt a result of any error so Unity will never ālearnā to stop wasting our time. However, when using option 2 I feel like thereās not really a good reason for Unity not to recompile scripts automatically when we press play, since this is a normal and expected function of development software. There is no case when a developer would want to enter playmode without using the up-to-date scripts.
To go along with this. It would also be great if we could disable automatic compiling too. Nothing is worse than when I save a file and it starts up a process that makes my CPU sound like itās about to vtol off of an aircraft carrier and suddenly everything starts grinding to a halt for a few second while Iām still actively trying to type.
I have just recently disabled auto-refresh and wrote a small script that does an AssetDatabase.Refresh when exiting edit mode. Iāll share tze script when Iām back at my computer.
if modified scripts exist, this will cause a recompile, otherwise nothing happens
only issue being that if you launch Multiplayer Playmode the recompiled scripts will not take effect in the virtual players
Wait? Is this new? Does disabling auto-refresh actually apply for scripts in Unity6 now? Iād actually consider upgrading my project just for this alone.
It always has?
Iāve had it off as far back as Unity 2020 where scripts would only recompile when I specifically hit CRTL-R.
That hasnāt been my experience in the last year. Itāll work fine for assets and for code that hasnāt yet been picked up but not for code already in the project.
Though Iām wondering now if there isnāt some weird interaction between Visual Studio and Unity that is forcing Unity to recompile any time I save.
EDIT: Ah yep. There it is in the Unity Tools options of Visual Studio. I feel great knowing this now! But I also feel awful. This is why I canāt have nice things. Me.
It may also be confusing because there are cases where recompile still does occur. Mainly if some editor script or internally Refresh() gets called. Most notably if you make any change to an assembly definition.
Sorry, I was expecting people to follow the links for context. Iāve updated the post with a full explanation.
This is my script to auto-recompile when entering playmode (exiting edit mode actually) if auto-refresh is turned off:
using System;
using UnityEditor;
using UnityEngine;
namespace CodeSmileEditor
{
/// <summary>
/// If Preferences => Asset Pipeline => Auto Refresh is disabled, will call AssetDatabase.Refresh() before
/// entering Playmode to ensure Playmode always uses the up-to-date versions of assets and scripts.
/// </summary>
/// <remarks>If no assets have changed this script will not slow down entering playmode.</remarks>
internal static class RefreshAssetsOnEnterPlaymode
{
private const String AutoRefreshKey = "kAutoRefreshMode";
private static Boolean IsAutoRefreshDisabled => EditorPrefs.GetInt(AutoRefreshKey, -1) == 0;
[InitializeOnLoadMethod]
private static void InitOnLoad()
{
EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
}
private static void OnPlayModeStateChanged(PlayModeStateChange state)
{
if (state == PlayModeStateChange.ExitingEditMode && IsAutoRefreshDisabled)
AssetDatabase.Refresh();
}
}
}
Itās one of the cases where I condone the use of AssetDatabase.Refresh(). 
Like I said, if you use Multiplayer Playmode and script compilation occurs, the Virtual Playersā scripts will be out of sync. But knowing that, itās quick enough to hit stop even while compiling, then press play a second time.