Skip to content

Instantly share code, notes, and snippets.

@jbubriski
Forked from mrcarriere/StopPlayingOnRecompile.cs
Created November 8, 2016 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbubriski/d101a96ecf69fbd9e72af0de902722fe to your computer and use it in GitHub Desktop.
Save jbubriski/d101a96ecf69fbd9e72af0de902722fe to your computer and use it in GitHub Desktop.
Force Unity to stop playing if you have edited a source file. Helps avoid some editor crashes and false positives / error spam. To use, drop this script in an "Editor" folder in your project.
using UnityEditor;
[InitializeOnLoad]
public class StopPlayingOnRecompile
{
static StopPlayingOnRecompile()
{
EditorApplication.update += () =>
{
if (EditorApplication.isCompiling && EditorApplication.isPlaying)
EditorApplication.isPlaying = false;
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment