Don't compile while running?

Any time I make external code changes to any component that is currently being used, my game will always hang when returning to unity, and often, if I don’t stop play mode immediately after returning, the editor will often just outright crash. Is there any way to turn off compiling while in play mode? It seems silly to always compile code when returning while in play mode as I’ve never actually seen it work without just dropping a torrent of errors.

Edit: Here’s a video example of the issue.

Any code changes will result in the game freezing and the audio freezing (since the audio buffer is filled using OnAudioFilterRead). If I stop execution right away, it will leave play mode properly and everything’s good, if I delay though, like in the video, the editor will just outright crash. Does it ever actually work, compiling while in play mode. :frowning:

You can possible move your code into a c# dll or use EditorApplication.isCompiling flag to do something.

buuuump this is a good idea after using unity for 7+ years lol

https://feedback.unity3d.com/suggestions/editor-must-stop-recompiling-scripts-when-playing-it-always-crashes-the-game?_ga=1.164091708.2050027250.1489787241

1 Like

There’s now a preference for this in:
Edit > Preferences > General > Script Changes While Playing

You can set it to:

  • Recompile After Finished Playing
    or
  • Stop Playing and Recompile
7 Likes