Editing code while in run mode causes Unity 2021 to hang / crash

If I edit code while Unity 2021 is running, then switch back to Unity, it will crash or hang.

In Unity 2019, 2020 there was a failsafe here where it would exit play mode when switching back.

You probably didn’t mean to say “crash” as that implies the editor crashing. Most likely the assembly reload will cause scripts to throw exceptions due to losing references, thus preventing playmode from working until restarted.

2 Likes

I’ll try recompile and continue, thanks.

Currently “stop playing and recompile” causes Unity to hang indefinitely.

This only happens while in Playmode?

An infinite compilation loop is something that can happen if you generate or modify scripts (or assets like folder names) when an assembly reload occurs and there’s a bug that causes changes to the generated/modified assets to change every time, thus triggering another compilation/reload phase.

Make sure it’s not something like that, like an editor script that does something with the AssetDatabase (or general File I/O) upon shutting down Playmode (or even at runtime).

can confirm it’s not.

submitted as a bug (happens anytime I edit code in runtime)

Thank you again
for your bug report.

Your bug report has been resolved as Not Qualified.