How to release Unity's lock on external DLLs?

So I’ve started trying out a workflow - I want to compile my DLLs from VS and copy them for use from within Unity.

The principle works fine, but it seems that once I’ve loaded the external DLL, Unity won’t release its file lock on it unless I quit the IDE, so I can’t easily replace it with updated versions.

Is there any way to completely stop the script execution engine, so the lock can be released?

I haven’t seen this issue here at all, and I am doing the same thing.

  • Build a fresh DLL in VS.

  • Copy it to my project directory overwriting the previous copy.

  • Open Unity and wait for life to recompile, or do cmd-r myself.

Sounds like you have another problem going on here…
-Jeremy

In the last step, you wrote “Open Unity” - does that mean you actually restart Unity for each cycle?

Or do you just use a Unity “stub” - a pre-built Unity exe with just a single launcher script kicking the external DLL, and be done with the IDE altogether? I’ll be going there eventually, but while getting started with Unity I think it might be of some use.

The game will not allow you to modify the DLL while it is running.

As there is no Editor for Windows, there is no other exe currently

Well, I do try to stop the game, by clicking a second time on the Play button in the lower left-hand side of the UI. Is there another way?

“No other exe” - not sure what you mean. It’s possible to create Windows executables from Unity on the Mac, no?

Yes that is possible.

The alternative way to stop the play mode is cmd-p
I only use the buttons there to pause the game if I need to check the logs for example.

As a note, by “Open Unity” I mean switch focus back to the editor, which will either trigger a re-compile, or I force it manually otherwise.

If I do not switch focus off of the Unity editor and copy my files over from my networked windows machine, then I have to force Unity to recompile.

-Jeremy

Cmd-P seems to be equivalent to the Play button. Either way, it doesn’t help - the DLL is still locked. Also tried Refresh, same thing.

I guess I could read the DLL as a binary stream first and instantiate it from memory instead of the file, but that’s ugly. Not sure what happens with conflicting assemblies in the same AppDomain either. Any other ideas?

(BTW, is it just me, or is the server this forum is running on really slow…?)

Did you minimize / push away the editor? while it is in focus it does “realtime compilation” (Unity works similar to Eclipse on that end) which will not allow you to modify any assembly as they are locked for assembly reference access

You only need to stop playing and put it in the background by making another app active and the assembly should be “unlocked”

Is Cmd-H equivalent to what you’re describing (I’m new to OSX)? First I stop, then hide with Cmd-H, and then try to copy the file… same message as before: “The operation cannot be completed because the item [ ] is in use”

I resorted to Assembly.Load(File.ReadAllBytes(file)). Ugly, but only necessary while developing, so I don’t really mind.