Skip to content

Instantly share code, notes, and snippets.

@synchrok
Created April 18, 2019 02:21
Show Gist options
  • Save synchrok/ec85532072fb6838bfe2a9afcc14c4f9 to your computer and use it in GitHub Desktop.
Save synchrok/ec85532072fb6838bfe2a9afcc14c4f9 to your computer and use it in GitHub Desktop.
using UnityEditor;
[InitializeOnLoad]
public class DisableRecompile {
static bool waitingForStop = false;
static DisableRecompile() {
EditorApplication.update += OnEditorUpdate;
}
static void OnEditorUpdate() {
if (!waitingForStop
&& EditorApplication.isCompiling
&& EditorApplication.isPlaying) {
EditorApplication.LockReloadAssemblies();
EditorApplication.playModeStateChanged
+= PlaymodeChanged;
waitingForStop = true;
}
}
static void PlaymodeChanged(PlayModeStateChange stateChange) {
if (EditorApplication.isPlaying)
return;
EditorApplication.UnlockReloadAssemblies();
EditorApplication.playModeStateChanged
-= PlaymodeChanged;
waitingForStop = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment