Skip to main content
Search our knowledge base

How to stop automatic assembly compilation from script



  • dirk

    This worked perfectly. Much appreciated.

  • Morte

    FYI, since Unity 2017.2, these warnings for lines 21, 33 make the above editor script ineffective as-is:

    Assets/Editor/CompilerOptionsEditorScript.cs(33,27): warning CS0618: `UnityEditor.EditorApplication.playmodeStateChanged' is obsolete: `Use EditorApplication.playModeStateChanged and/or EditorApplication.pauseStateChanged'

    Assets/Editor/CompilerOptionsEditorScript.cs(33,27): warning CS0618: `UnityEditor.EditorApplication.playmodeStateChanged' is obsolete: `Use EditorApplication.playModeStateChanged and/or EditorApplication.pauseStateChanged'

    Per suggestion, fixing the capitalisation from




    gets a different new error:
    Assets/Editor/CompilerOptionsEditorScript.cs(33,27): error CS0123: A method or delegate `CompilerOptionsEditorScript.PlaymodeChanged()' parameters do not match delegate `System.Action<UnityEditor.PlayModeStateChange>(UnityEditor.PlayModeStateChange)' parameters

    which appears related to the issue noted here:

    and as some current doc illustrates,

    The new function takes one parameter, so the delegate method in the above editor script needs to be updated with a valid matching parameter, e.g.
        static void PlaymodeChanged(PlayModeStateChange state)

    however the delegate method does not currently do anything with that state variable, and in some circumstances the following line:
    if( EditorApplication.isPlaying )
    can be replaced with something like:
    if (state==PlayModeStateChange.EnteredPlayMode)
    but it will probably work as-is.

    Refer to the doc on the exact meaning of those state enumerations:

    The old function name will work up to and including 2017.1

  • Ivan Zverev

    As of (at least, Unity doesn't pay me to QA) 2021.1.5f1, this no longer works (even with the proposed changes to get around the obsolete warnings). The if condition in OnEditorUpdate is never hit, even if you are in play mode and compiling. The isCompiling flag is never set to true before compilation is triggered and you start the dreaded null reference exception parade.

    I was able to get around this by just removing the isCompiling flag (you still get a short "is compiling" popup in unity, but it doesn't seem to go any further

  • Jake Pollard

    Using Unity 2021.2.19f1, Edit > Preferences General does not have an Auto Refresh option and the first script in this article is cut off, so I'm unable to test that.

  • KYL3R

    Jake Pollard - Auto Refresh moved here:

    Edit -> Preferences -> Asset Pipeline -> Auto Refresh


  • Morgan Klein

    click the drop-down to the right of Script Changes While Playing and click Recompile After Finished Playing. => Does not work on MacOS (Silicon) with Unity 2021.3.0 (LTS) if you don't check ALSO "Auto Refresh"

  • Victor-Iuliu Navratil

    If with auto-refresh disabled, your scripts still continue compiling I might have found a solution (in my case). I have spent a few hours trying to figure this out and hopefully this will help someone.

    I am using Unity 2022.2 and Unity 2021.3 (LTS) with the latest version at the time of writing this comment.Auto refresh was off but I've seen that 2 different projects had different versions of Burst. And in both cases Burst had the "chain link" icon (installed as a dependency)

    The solution in my case was: I reinstalled Burst by name (Packager Manager -> "+" sign -> "Add packager by name.. -> added "com.unity.burst"). Installed version is 1.8.4.This seems to have solved it. Some settings might have been reinitialized.

  • Chris Hammond

    For many this solution won't work, you have to change settings in visual studio to stop it from updating Unity assetdatabase everytime a file is saved:


Please sign in to leave a comment.