Unity 2017.3: Speeding up Compile Time with the New Assembly Definitions

20 December 2017

Unity compile times, before and after Compile Time (AKA: thumb-twiddling time) Comparison

In Unity, each time you make any change to your C# code the entire project is recompiled. This can take anywhere from a couple of seconds to minutes, depending on your computer’s hardware, the size of your project and number of plugins.

Thankfully, a new feature was released yesterday in Unity 2017.3 which allows you to selectively recompile certain files, instead of the entire project. This can greatly speed up your development time, as you typically do not change code in your 3rd-party plugins.

Read on for a quickstart guide on how to get this working for you.

Assembly Definitions: Quickstart

I followed the same layout which was provided by Unity in a sample project one of their devs they linked to. I’m unable to find that same sample project at the moment, but the general layout looked something like this:

  • Assets/AssetsRoot-ASM.asmdef (References: Plugins-ASM.asmdef)
  • Assets/Plugins/Plugins-ASM.asmdef (No References)
  • Assets/Plugins/PostProcessing/Editor/PostProcessingEditor-ASM.asmdef (References: Plugins-ASM.asmdef) and (Includes: "Editor"-only!)
  • Assets/Scripts/ScriptsASM.asmdef (No References)

In Unity 2017.3, you can create a new type of file called “Assembly Defintion” the same way you would create a sphere, cube, script, shader, etc. (using the “Create” menu). Place each of these Assembly Definition files in the directories you want to control using Assemblies.

For the tiny project I’m currently working on, I was able to shave a couple of seconds off (from 8 seconds to 5.5 seconds) by avoiding recompilation of the 4 plugins I’m using when I change my scripts. I haven’t tested this on one of the larger projects I’ve worked on yet, but I’m excited to see how much of a difference it makes.

Happy performant game developing!


Chuck Bergeron's photo
Chuck Bergeron Full Stack & Blockchain Developer