Hi, i’m struggling with this bug all day, I’m on version 2019.2.12f1 of the editor:
When I open up a new project and add a new C# script in the project tab (Right click->Create->C# Script),
I suddenly get an error on the console window which prevents me from entering playmode:
“Copying assembly from ‘Temp/Assembly-CSharp.dll’ to ‘Library/ScriptAssemblies/Assembly-CSharp.dll’ failed”.
Sometimes I get several errors of this kind (Copying assembly from ‘temp/x.dll’ to ‘Library/ScriptAssemblies/x.dll’ failed), sometimes I get only 1.
I have done nothing in the project but add a single script and haven’t touched any of the code inside it.
I have already searched in google for the answer and the answers are usually:
‘reimport your script’ (did that, didn’t work).
‘check if there is an antivirus that interferes with the scripts’ (I have none installed).
‘delete all files from the temp folder and restart the project’ (tried, didn’t work).
Hi! It should be something external to Unity blocking the copy operation from the Temp folder to the Library folder.
That could happen, for instance, if you don’t have enough space in your disk or if there is another process using that files/folder (usually an antivirus).
Also, you mentioned you deleted the Temp folder, but actually, it’s more likely that the problem is in the destination folder, which is the Library folder, have you tried deleting the Library folder?
Please take into account that deleting the Library folder, will cause the entire project to be reimported.
And finally, be careful when touching directly those folders and files, make sure first you have somewhere a copy of your project.
Is there a way to force Unity to try and copy again? Right now I have to edit a script to induce an error (generally I remove a semi-colon), switch back to Unity to get it to recompile/copy again, then back to the script to fix my error, and then back to Unity for recompile/copy. It mostly works, but it’s tedious.
It should be any script in the Assembly-CSharp, or in other words, any script in your project that is not part of an Assembly Definition.
I have just checked it and it works for me, the Assembly-CSharp.dll file gets updated, that is because reimporting a script will recompile it and then update the Assembly.
Don’t know if this helsp, but for me the culprit was Dropbox. I had my Unity project in a Dropbox folder and was getting those errors all the time. Probably Dropbox indexing the files etc… After moving it to a different folder, everything works fine.
We had problems with this issue and we expect it to be caused by a Windows group policy, since all computers in the company have the same problem.
Here is what we found that can highly reduce the frequency of the problem:
Change setting to “Edit/Preferences/General/Script Changes While Playing” : “ Stop Playing And Recompile”
Use a Unity version 2020 and up
Upgrade laptops, that where are not intended for Unity development / lack in performance (I don’t know what bottleneck(s) will affect the frequency of the problem).
Hopefully this will reduce the frequency of the problem to almost 0. When it still happens, there is no need to restart Unity (like I first did…). What you can do is “right click/Refresh” on the folder (or script) with scripts that where changed.