How Can I Reduce Build Time for Script-Heavy Projects?

My current Unity project now has build times at around 4 hours (!!!). I had previously assumed by computer was underpowered or short of memory, but having just upgraded the machine I’ve seen little improvement.

Research on the internet suggests that scripts with non-private fields can cause problems, so I’ve been through my entire source base (over 1MB of code!) making as many things private as possible. Unfortunately that’s had nowhere near enough impact. Most classes still have 3-5 public variables and the scale of the refactoring job needed to remove them would be vast (many weeks of work, at minimum). Even if I did, they’d only be replaced with public functions, which presumably isn’t much better?

What can I do about this? I need to get my build times down since I’m approaching alpha release for the project and need to be able to iterate builds quickly. Or, failing that, at least not have to literally do them overnight!

Well, unlikely or not it turns out it is a Unity bug. Now submitted at: FogBugz

To reproduce it, open a new project with no assets. Create three scripts and remove all code from them. For two of the scripts, add one variable of the type implemented by each of the other two. For the third script, add 20 variables of each of the other types. The resulting project ought to build instantly, but actually takes ~30s.

I’ve tried it again and yes, if i have a circular dependency (which is quite unusual) the building takes around 90 seconds. However only without pragma strict. I’ve done the same test with pragma strict and even in C# and the build time stays normal.

There’s no reason to use scripts without pragma strict, it’s even in new scripts by default and a recommended performance improvement

scripts without pragma strict allows you to write very unefficient code so you shouldn’t complain in such a case.