Unity was freezing, and now it won't open because of this error.

I’ve been working on this project for the past several hours with no error, and now I’m having editor problems all over the place all of a sudden. No, I haven’t tried restarting my computer yet, but I will after posting this question in frustration. Maybe someone will have an answer by the time my laptop boots back up (hopeful much?).

First things first, I’m now receiving this error message upon clicking on the Unity icon to open it up: Moving Temp/Assembly-CSharp-firstpass.dll to Library/ScriptAssemblies/Assembly-CSharp-firstpass.dll failed: Access is denied. My button options are ‘Try Again’, ‘Force Quit’, or ‘Cancel’ to which Try Again does nothing (does it ever?).

Before I started getting this message, Unity would freeze up when I’d press the play button to test the changes I made in UnityScript. Honestly, the last change I made before the freezing started happening was adding a print statement inside a function that swapped out textures of a material on an instantiated Game Object. The objects are cubes and the textures are only different on once face. I wanted to add in this print statement to know it ran. If it did indeed run and I couldn’t see the new texture, my next plan was to use different textures of a solid color to notice the difference (because maybe my cube was rotated the wrong way), but I didn’t get a chance to test it because of it freezing.

If the computer restart doesn’t work, I’ll go hunt down that temporary file in the message and delete it. Oi. Frustration.

This is just how my life always is; by the time I decide to finally post my problem after researching for existing solutions, I end up solving it myself shortly after - always making me look like an idiot. For anyone else that came across this issue, these are the steps I took to solve this error.

  1. Shut Off computer (not restart).
  2. Turn on computer.
  3. Open Unity Editor (and your project, if not already)
  4. Remove all scripts (or maybe just the ones you suspect to be causing problems) from objects in each scene.
  5. Save and then test game to see if editor does not freeze from any script’s removal.
  6. If it doesn’t freeze, save, and start to add the removed scripts back to the objects in each scene.
  7. Just in case, save and test between each addition.

Hopefully it didn’t break and you can continue working.

Or just start a new project. This also fixes it.

If you close Unity, delete the entire Library/ScriptAssemblies directory, it is regenerated the next time you start Unity with that project. It is some sort of permissions error that can appear when Unity crashes.