Unity 2021.1 Script Compiling Time Dramatically Increased?

I was using 2021.1 this weekend for a game jam, and it dramatically increased the time of re-compiling scripts whenever a change is made. I’m talking like 10-15 seconds from 1-3 seconds in 2020.3. Is there a reason for this and is this a known issue or is the engine just getting more bulkier? I did notice that donotdestroy objects persisted in my scene hierarchy a little while after play mode is over, so something fundamental to the loading process seems to have changed.

1 Like

I don’t recall any significant changes in script compile time between Unity versions I’ve used, and I’m pretty sure I gave that one a spin.

My first question would be, if it was a game jam did you have any 3rd party libraries / packages / assets in your project which are different to usual? That includes Editor extensions.

There’s two parts to “compiling” in Unity. The first part is the compiling itself. The duration of this is hugely impacted by how much code there is to recompile. If you’ve got lots of code then using Assembly Definitions to split it up helps, because any assembly which doesn’t depend on what you changed doesn’t need to be recompiled.

The other part is loading the newly compiled code in. This is often the slower part because it requires serializing and then deserialising all data which depends on your scripts.

Or, it’s also possible you found an actual performance regression somewhere. If the same project in a different version of Unity is measurably faster then you should report that as a bug.

I’ve seen something that looks like this, but I was under the impression that the Hierarchy display just wasn’t being updated immediately. I think that’s being done asynchronously now, but am not entirely sure.

1 Like