Generating Unity builds continuously, for game development, using personal computers is no fun-game. Manually generating them is much more vexing because each build takes a lot of time to configure and compile. Moreover, these builds are slow on personal computers due to high memory utilization and are prone to frequent human errors.
Automating build pipeline and offloading them from the developer machines into the “cloud” or using build platforms like Travis CI or CircleCI seems plausible. However, due to higher costs, developers are coerced to take an alternative route.
Here’s our story of why we built BuildBot, the open source build pipeline tool for Unity builds.
We, at TotalCloud.io, have been leveraging the Unity3D platform to build our immersive visual cloud management platform since inception. Without a doubt, Unity3D is a wonderful multi-platform game engine, be it for game development or non-game interactive simulations and visualizations.
However, it has been quite a challenge for us to tackle the high time-to-build on Unity 3D. Sometimes, the time taken to generate one build was close to an hour. At times, we push close to 10 builds per day! Now, imagine the insane amount of time we spent just on generating the builds. We wanted our developers to see changes in the builds as soon as possible, without waiting for hours.
To top it, as the time-to-build increased, so did the cost. We were in dire need of a solution that could automate builds in a very short span of time without using costly build platforms.
Just like us, one of the significant factors that keep indie game developers and small studios away from build platforms or CI solutions is the cost incurred to generate builds of a game. Unlike big game studios who might leverage on-prem build servers or CI servers to continuously generate their builds, these indie developers or small teams do not have that kind of money to splurge on hardware and other build platforms.
So, if a game developer generates 10 builds per day, the total cost incurred per month will run into hundreds of dollars, which is heavy on the pocket.
Apart from the cost and time factor, there are other drawbacks of manually generating the Unity builds, such as:
All these factors lead us to build TotalCloud Buildbot, the open source build pipeline tool for Unity builds.
Now let’s dive deeper into cost per build.
Let’s assume you generate ten builds per day, with the ability to do three builds in parallel. This accounts for approximately 300 builds per month. If each build took close to 30 minutes, then you will consume ~9000 minutes of build time per month. Now let’s make a quick cost comparison between different build platforms:
This clearly shows that using AWS is one of the most cost effective solutions.
Hence, we leveraged AWS and built the BuildBot, an open source on-demand build pipeline tool that allows an indie developer or small teams to generate hundreds of builds per month at a fraction of the cost compared to any other solution available in the market.
The reason to go with EC2 spot instance with Windows Base AMI and i3.large machine instead of Mac OS is that generating Unity builds in Linux is very unreliable and doesn’t work most of the times, because of headless mode issues. On the other hand, AWS does not have Mac OS AMIs. This leaves us with Windows machines.
And, i3.large is a big machine with 15.25 GB memory, 475 SSD storage, high read write capacity and good CPU, which is enough to generate bigger builds. Plus, we are going to leverage NNVM SSD volumes to generate the builds faster instead of using the inbuilt EBS volumes.
Since a build machine needs to come up only when required, we are going to leverage AWS Spot instances to achieve cost savings. Because, i3.large spot instances cost ~$0.0468 USD per hour at 70% discounted rates. We can easily stop the machine when not in use and spin it up quickly when a new commit is available. We will talk more about it in our upcoming build pipeline post. For now, let’s walk you through the steps on generating Unity builds in AWS.
1. Launch and connect an EC2 Spot instances from the AWS console with Windows 2016 Base AMI and i3.large instance type. For developers who are new to AWS or want a quick walk through on how to launch an i3.large instance type from AWS console, click here.
2. Inside the Windows machine, launch the Powershell ISE from the Start menu. Create two files with the below Powershell scripts. The first script is to create an additional SSD volume that is required to generate builds; and the second script is to install Unity3D on to the Windows machine quickly.
Here’s the script to create the additional NNMV SSD volume. In the script we will name it ‘Jenkins Volume’ because it will be a part of our Jenkins Build Pipeline.
Here’s the script to install Unity3D engine.
P.S: Ensure you save this Powershell script in C drive.
3. Look for Unity setup in the Unity folder from C drive and install packages for Windows, Linux as well as MacOS.
4. Wait for Unity to setup.
5. Download your code from the Repo and look for the path of the project you want to compile the builds.
6. Create a BAT file to automatically store the builds as they are generated. Here’s an example of a BAT file. Make sure you add the right paths to the respective commands. Example: Use the project path URL you used to save the project in line 2 of the code (inside quotes).
7. Try generating a new build and check if the new build is available in the Output path and the log file in their designated paths.
Do try it out and share your experience.
This is Part 1 of the three-part series blog providing the stepping stone to using TotalCloud BuildBot. Stay tuned with us for our second blog, where we provide detailed information on how to go about the CI/CD pipeline using BuildBot.