WIP Unity Build Helper

Unity touts its multiplatform features all the time, but it’s still a pain in the butt to manage manually.
Unity’s custom script symbol defines are incredibly useful for building variants of your game, but it’s tedious to modify these every time you need to build different variants of your game, not to mention incredibly error prone. It’s also not friendly to automated workflows.
Additionally, if you have a lot of variants of your game, it’s tedious to make all of those builds and keep them organized. Plus, some kind of versioning system is absolutely essential.

So, I decided, why not write a tool which solves all three of these problems?

The idea is this: in the Build List Manager, you define a list of platforms you want to build. Each platform has a Build ID (just meant for your own organization), a list of custom script define symbols, and a build target.
From there, you can Load a platform’s settings into the editor (for testing), Build that platform individually (also for testing), or Delete the platform. Or, you can build all of your platforms in one click with the Build All button.
There’s also a simple version scheme built-in. A game’s version number is defined by Major Version, Minor Version, Version Type, and Sub-Version. This forms a version string of the format x.y.zw, where each letter is one of the respective aforementioned components. Version Type serves to identify the purpose of a build. The list is Indev, Alpha, Beta, Release Candidate, and Full, which translates to the version string as ‘dev’, ‘a’, ‘b’, ‘rc’, or ‘f’ respectively.
Each Build All operation increments the sub-version automatically. You can also:

  • Upgrade the version type (up to Full). Resets sub-version to 1
  • Add 1 to the minor version. Resets version type to ‘Indev’, and sub-version to 1
  • Add 1 to the major version. Resets minor version to 0, version type to ‘Indev’, and sub-version to 1.

The version string is queryable from your game’s script code as well.
It also supports custom pre/post build operations, simply by dropping a script in an Editor folder which implements the ICustomBuildOperation interface. You get callbacks for PreBuildAll and PostBuildAll, plus PreBuildPlatform and PostBuildPlatform for each platform it builds.

So, let’s say you’re working on a game which you want to deploy to a number of mobile platforms. It’s also multiplayer and server authoritative, so you’ll want to build a game server as well.
Your project will deploy to iOS, Google Play, Amazon, and OUYA. We’ll say you also want to deploy demo and full versions of your game. That means two builds per iOS, Google Play, and Amazon (OUYA uses IAP instead of having a separate demo version).
If you have Windows and Linux server builds, this totals to 9 different build variants.

So you’d define these in the build manager, like so:


Your script uses #ifdefs to conditionally compile code depending on the tags defined (that way you avoid having unnecessary code in the final build - for instance, you wouldn’t want OUYA code in your Google Play build)
Now, you can make individual builds for these platforms, OR you can hit the Build All button at the top to build all of those variants in one go.
There’s also support for batchmode processing - BuildUtility.BuildAllPlatforms can be passed to the Unity Editor ‘executeMethod’ commandline argument. I could easily envision scenarios where you could set up a Build Server of sorts, with custom pre/post build operations such that:

  • The build server first checks the project out from version control
  • All platforms are built
  • Built binaries are uploaded to various servers over FTP for distribution

Thoughts on this? Are there any features I should add?

OMG this is a must on every freakin Unity - downloaded computer!!!

Thanks for the kind words :slight_smile:
This is something that has been a bit of a sticking point for me in the past, and as with anything in Unity I’ve realized it can be solved with an editor extension.

Hm, it occurs to me that sub-versions perhaps should be kept track of separately per-platform. Reason being, if you need to make a change for only one platform (maybe you fixed a Google Play related bug or something) you still want to update the version number for that platform, but you don’t want to release an update for all platforms.

So I’ve made a change to the build helper.
Now, instead of having a single “Sub version” number, you now have a per-platform “Build Number”. Every time you build that platform, the build number increments. This is regardless of whether it’s a test build or a full build - it increments every time. I decided that it didn’t matter how much this incremented between public releases, just that it was a unique number per build. (I could even have gone with a timestamp, if I wanted - which is what .NET’s version numbering scheme does). It still resets in between version type upgrades, minor versions, and major versions.

Additionally, instead of displaying the full version number at the top of the build manager, it only displays the partial build number (major, minor, and build type - no build number), and the build number is individually displayed next to each platform.

Today I added a build report system. It’s nothing terribly fancy, but what it does now is generate a BuildReport.html file after you perform a Build All operation.
This report contains:

  • The version number
  • A list of platforms which were built
  • If any platforms failed to build, lists how many
  • The date and time of the build
  • A table of build results (build ID, whether it succeeded or failed, the build output message, and the build number)

So for instance here’s a sample build report generated from the build process.
1650130--102941--DFBuildReportSample.png