Is there anyway to prevent the Unity Editor from crashing during play mode when using external DLLs?

I have a C++ DLL that is frequently accessed in the game loop and sometimes I write code that crashes in the DLL :slight_smile: which crashes the Editor. Is there anything I can do to make that workflow smoother or are Editor restarts just the nature of the beast when debugging C++ DLLs?

Making your DLL more stable will help. You can test your DLL outside of Unity until it is stable.

Also use Unity - Scripting API: MonoBehaviour.OnApplicationQuit() to run shutdown code for your DLL when the user leaves playmode, to stop your DLL potentially doing things in the background.

One thing which I have never managed to work around is that if you modify C# code while your game is running and refocus Unity it reloads all the code, which can be disastrous when the code uses native plugins, as you donโ€™t really get a good opportunity (at least, not that Iโ€™ve found) to properly tell the plugin what is going on.