I’ve asked this question before, but due to the nature of these stack overflow-like forums, any modifications to the question do little to bring it to anyone’s attention, and making substantial changes to a question are frowned upon.
So, I’ll try asking this in a different way.
I need to replace a plugin DLL frequently, as it is part of the testing process. I build the DLL with MSC, and run it with a C# script in Unity. The problem is, after it is used only once by a script, the module remains in use until the editor is restarted (that is, I cannot delete or replace the file, either manually or through another program).
This tells me that the C# runtime that Unity is using is not releasing references to modules that are not in use after scene scripts have stopped running.
I wrote a little test module that produces a message box when DllMain gets called with DLL_PROCESS_DETACH
. After I run and then stop a script that loads it, the message box does not pop up until I close the editor.
I understand that the runtime dynamically loads the script and its dependencies while the editor is running, and playing/stopping the game does not necessarily mean that any modules loaded by scripts are unloaded.
MY QUESTIONS ARE:
How can I force the editor to unload a module without having to restart it?
Is there a list of loaded modules somewhere I can access that would allow me to force an unload?