October 2021: Added a few nice features that improves the Quality of Life for developers. Now, every build writes out a version.txt file that lets you easily get at the built player version number in build scripts. I use this to fix the .exe version number, since Unity doesn't do that for us. See the docs for details. Also fixed it so the Application.version call produces the correct version number, which lets you log it our or put it on screen for troubleshooting purposes. Last, but not least, there's a WaitForManagedDebugger checkbox now that puts a built client into the correct mode for attaching a debugger--super handy and pretty hard to find normally since it's part of the UI that Unity hides from you until you check the right boxes. Bizarre to hide something so useful.
September 2020: Added a major new feature: Self-Contained builds. Now you can check a single checkbox, build your app and the bundles will automatically be placed into the /StreamingAssets/ folder and the paths patched up to load everything internal to the app. Several people were asking for this, and that's a pretty strong sign there are folks who find Asset Bundles and build management useful without going through the hassle of hosting anything. Also included in this version is much improved error logging to the Console window, which should lead to people being able to understand hosting issues and solving them more rapidly without needing help. I also adjusted some of my test bundle paths to be easier to manage, and hopefully easier to understand. Finally, AutoBuilder has been tested on Unity 2020.1.6 works great, so I'm now hosting test bundles. The documentation has been significantly updated as well.
After much experimentation and refinement, I am pleased to announce the best Unity asset for managing player and data builds, all in one package, on the Asset Store. I built it for my own projects, because Unity really does expect you to write a bunch of code before you can usefully produce multi-platform builds, especially if you want to use asset bundles.
What did I try to accomplish?
Mainly, I started with trying to get Jenkins to run a build of a single platform and produce a Player. The amount of effort required to do this well was non-trivial. Not only that, but I've seen several build systems at different companies and all of them required code changes just to change a build setting. I didn't want any of that. So, I built a system that uses a ScriptableObject to hold settings. Then I added a nicer custom Inspector to make it easier to edit. Before long, I added multiple platforms with independent settings blocks. And more became more, and so on...
And then I wanted Asset Bundles.
Also, I desperately wanted to be able to have a tight download for mobile, and let the game grab assets from the web automatically. And work for multiple platforms. And for multiple versions of built players, simultaneously. Some games are tolerant of older clients, some are not. I didn't want to require upgrading the player just because the data changed. So, I created a simple system for producing asset bundles that was easier than the mess Unity gives you. There's no tagging of assets, and no duplicating data to help resolve cyclical dependencies, and no need for an asset bundle browser... why? Because the file system should literally be your asset bundle organization. Operating Systems already have excellent tools for moving files around, just use them. In the event of a cyclical dependency, my build system tells you what the assets are that can't resolve, so you can move them someplace more central and shared. But you really don't have to worry about what order bundles are loaded in--AutoBuilder does that for you.
What's so unique?
The thing I think sets AutoBuilder apart from the pack is it comes out of the box with a workflow that encourages using asset bundles in the Editor. Normally this is prohibitive, because building bundles takes a longish time, and you don't want artists constantly waiting on that to resolve before checking their work. So instead, I built an override bundle system. This is critically amazing, because it is really fast to detect all modified assets, and sweeps them all into a special asset bundle that is built really quickly and is the first place the runtime looks for loading things. This means you can iterate quickly on textures or terrain or prefabs or whatever, and you click a button and you're ready to run with full asset bundles right in the edtior. No special loading mechanisms, and no performance hit for running in the editor. Test the actual asynchronous loading code that your built player depends on all the time instead of just when producing builds, where debugging is easy and iteration time is quick.
What else comes in the package?
I wanted there to be a simple way to launch the game that always works, always ensures that the matching set of data is loaded for the executable, and manages the cache so old data is removed when no longer needed. So there's a launch scene included that does all this for you, while showing an example progress bar that moves smoothly while downloading, displays some text progress, and just works right out of the box. All you have to do is skin the artwork and fill out the name of the next scene to load when all the bundles are downloaded, and it just lauches your scene when it's ready.
Also, there's full CDN support and flow-control support for A/B testing. The very first thing that happens when the loading scene starts up is a URL is requested that delivers a .json formatted file. This can be a simple file hosted on a web server, or it can be a .php or .js that generates a file based on whatever criteria you choose. Part of the payload that it sends down is the address of where to pull the bundles from, which is usually a CDN (like CloudFront or Akamai), but in the event the CDN is down or changes, you just change the .json file and repoint all the existing clients someplace else. This means you can react quickly without having to rebuild your game and distribute it--which is not really possible on many platforms, anyway. Apply, Sony, Microsoft, and Nintendo all take more than a few minutes to push builds to gamers.
Finally, in the event you just want asset bundles but don't know or care about hosting them online, there's a Self-Contained mode, where it all gets built and bundled into a single non-network-required package. Sometimes this is absolutely a requirement, turning it on is just a single checkbox.
Sounds complicated. How hard is it to use?
To write something like AutoBuilder, yes, it is. But using it is a snap! You don't need to write any build system code at all. If you are using asset bundles already, this is just a different way to produce them, but the end result is all your bundles are initialized by the time your first scene launches. Impact to your game is negligible, but the benefits are huge.
There's a menu that gives you the three important options:
- Build All Enabled Platforms
- Build [Current] for the Editor
- Build an Update for the Editor
The top one builds every platform you want to build, which you can control (entirely through mouse clicks) in the BuildConfig settings object.
The second one builds whatever "current platform" is set to and drops the bundles in your local runtime folder, so when you hit play in the Editor, it uses those bundles. (Note, current platform is so you can test win32 vs. win64 vs. Windows Store, or Linux32 vs. Linux64, or whatever, without leaving the Editor.)
The third one builds the override bundle that figures out anything you have changed since you built the full bundle set.
It's worth pointing out that if you are working on a recent build that has already been published to the web, hitting run in the Editor will automatically pull those bundles down, so you don't have to build them yourself. Then building the override is really fast, and you skip the annoying big builds. This is a huge reason to have a build machine, because it can automatically build and publish bundles for you, and you never have to wait. Which, by the way, AutoBuilder makes really easy.
Curious? Ask questions. I'm happy to answer them. This is the best solution out there. Give it a try, and please leave a review if you like it!