Whenever I modify any script in a project, Unity recompiles every single script in that project.
In a non-Unity project in Visual Studio, the compiler knows that it only needs to recompile the files that have been modified, and as a result of this compilation times are very fast.
In Unity, however, compilation takes much longer than it has to. An average compile takes about 10 seconds to complete for Unity, but takes only about 2-3 seconds compiling with Visual Studio.
Why does Unity do this?
Is it possible to make it compile only modified files somehow?
Even though it may not compile absolutely every script in the project, it still compiles a whole lot of scripts that haven’t been modified, which is the problem.
thats no problem, thats standard. you can’t recompile an assembly from a single file only, the whole assembly is recompiled and as unity does not support namespaces that means all scripts of this language in the same compile step.
But its normally no problem, we don’t see a more than 1s break even with projects having hundreds of scripts, all of them in C#
Visual Studio can produce a DLL of a Unity project by only compiling a single file, though I assume it keeps scripts that have been compiled previously around in object files or whatever C# uses. Unity does not.
It doesn’t help me much that compiling takes less than a second for you, for me it takes about 10 seconds. The project currently has over 900 .cs files.
I believe Eric is saying if you put scripts that don’t change in the standard assets folder, compile times will improve.
The best solution though is simply to buy a faster computer. My main desktop machine (which is s couple of years old) will compile complex projects in a couple of seconds, while my 6 year old, single processor machine can take several minutes.
If you read eric’s link you’ll see unity does kinda support it.
Scripts which don’t change much should go into: “Standard Assets”, “Pro Standard Assets” or “Plugins”. So all your stuff you’re not changing should go in there, which won’t be recompiled unless absolutely necessary.