Accelerating player builds with an incremental build pipeline

Posted by

The build graph described here includes all the steps for building players that can be run as external tools with clearly defined dependencies, such as:

  • Script compilation
  • Il2CPP conversion and C++ compilation
  • Code stripping via UnityLinker
  • Burst compilation
  • Code signing
  • Packaging and compression

It also includes many platform-specific tools. It does not, however, encompass the serialization of scenes and assets into player data files (which is currently done by native code in-Editor).

Unfortunately, there’s more to building a fully incremental data build pipeline than adding nodes to a build graph. Due to the nature of Unity’s data file layout, each scene depends on all previously built scenes, so we cannot simply extract small changes to build independently of everything else. This is a shortcoming that is being addressed by other teams at Unity, and we hope to see significant improvements in the coming years.

But even with these constraints, our team didn’t want to force any unnecessary work when users hit the Build button. That’s why we decided to automate the feature formerly known as Script only build. Once a checkbox in the Build Player window, this feature served to tell Unity to reuse the player data from the last build (ignoring any changes), and to only recompile scripts instead – in order to allow for faster iteration times on code. But we felt that this put the burden of tracking changes to player data on the users, a task that computers can handle with ease.

In the new incremental build pipeline, we track whether any of the scenes or assets being used in the player have been changed since the last build. If there are no changes, the Editor now automatically skips the data build, and reuses the data from the last build. This way, users get quick builds by default, without the mental overhead of having to track changes manually.

However, it is still possible to skip the data build – even if there are data changes – by clicking the Force skip data build option in the pop-up menu of the Build button. This can be useful if you know that there are data changes, but want to quickly test a code change, without applying the pending data changes for this purpose.