Quick introduction

Unity3D is a extremely useful game engine that spares you lot of efforts when you develop your game for multiple platforms. In the early stages of Unity, it was very difficult to have a smooth workflow with a small team. Everything needed to be done manually: building for one target, switching to another one and building again to another platform, sharing your build to your team through ftp or other file sharing service, and so on…

As we call it in the business – a real pain.

unity

Unity acquired Tsugi Builder in 2014, and then rebranded it Unity Cloud Build. That’s the birth of a brilliant new service that is a big time saver for all of us! Although it is now a premium service, so you have to pay. However when you consider the amount of time it’ll save, it is definitely worth the price of 9$/month.

What is continuous integration?

Continuous Integration, or CI, is the process of merging all developer codes that are then reviewed and validated to a central repository. Once that’s done, automated builds will start with tests on a seperate server. We use CI to integrate our features as frequently as possible, and to improve software quality by fixing our bugs early and often.

We usually set up our code with a version control tool, such as GIT or SVN with CI, as the CI server will watch any code changes pushed and will start the builds, test and release process.

continuous integration

Git + Unity Cloud Build = perfect combo!

After this quick introduction about CI, what about explaining how we managed to efficiently create a smooth workflow for video games made by Unity?

Here at Million Victories, we use Git for versioning. All our game code sources are versioned with GitLab service. We might write something about version control soon to help you set up a safe and stress free work environment with Unity and Git, but today we are speaking about UCB (Unity Cloud Build).

To be honest it might be a bit expensive if you are alone and making games as hobbist. But if you want to work professionally, it is worth taking their Advanced plan at 9$/month described below:

unity-plan

Don’t worry about the number of seats allowed (3), you will be able to share the build to other teammates through other channel such as Slack.

Once Unity Cloud Build is activated, you can decide to use the Unity Collaborate or to link your existing repository to it. In our case we are going to link our GitLab git repository to UCB.

Go to your UCB settings:

  • https://developer.cloud.unity3d.com/projects/
  • Select the project for which you want to activate the service
  • On the left side, you have to click on Cloud Build and then Config
  • There you will be able to enter the setup for the Source Control

Copy and paste your git repository URL here, select the Type to Git and save your changes:

unity git

You will obtain a SSH key that you will have to add to your git hosting service (GitLab, GitHub, Bitbucket, …).

Once that’s done and everything is correctly set up, you will have access to the dashboard with (even more!) settings.

It’s there that you can set up New Targets (eg. Android, iOS, …).

By default, Unity Cloud Build will set your target to build on the Master branch of your Git repository. This can be changed on the settings of your target by clicking on “Show Basic Info” and then by clicking on “Edit Basic Info”.

unity settings

Notify your team using Slack

With the Advanced plan, Unity Cloud Build gives you 3 seats for your teammates by default. You don’t have to worry if your team is bigger than 3 and you want to share automatically your builds to everyone.

We are a small team of indie developers and even with a team below 10 members, we needed some kind of continuous notifications when new builds were available. That way, everyone (not only devs) would be able to download, install and test the work in progress of the game.

We’ve created a Slack just for that purpose. Slack offers a free plan (yay!) and you can link your Slack account to Unity Cloud Build. In order to do that, you just need to go to UCB -> Notifications menu like below:

unity notifications

Click on the “Add to Slack” button, and log with your Slack account and select the event you want to be notified for.

And that’s it! Everyone on your team will receive a Slack notification on the #general whenever a new build is ready to be installed!

The user only needs to click on the Share link to directly download it for iOS or Android on their mobile.

Go further with pre and post export methods

What about if you need to execute some script during the Cloud Build Process, like getting the build number of Cloud Build or even changing some value on the fly?

Unity Cloud Build provides some advanced features for that: Pre-Export Method and Post-Export Method.

 How to use them?

First you need to create a script on your project like this, named “PostPreExportEditor.cs”

[c]
#if UNITY_CLOUD_BUILD
using System;
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;

public class PostPreExportEditor : MonoBehaviour {

public static void TestPostPreExport(UnityEngine.CloudBuild.BuildManifestObject manifest)
{
string buildNum = manifest.GetValue(‘buildNumber’, ‘unknown’);
Debug.LogWarning(‘PREBUILD Script launched, build number is ‘ + buildNum);
}

}
#endif
[/c]

On the UCB settings you have to make the following changes:

unity changes

So now each time a new build is done through UCB, the script PostPreExportEditor.cs will be called with the function you have specified. Here: TestPostPreExport.

The function I gave you above only displays the buildNumber on the console log of UCB. It’s not very useful I agree, but you can change that to fit your needs. At Million Victories, we are using it on our side to link the build version to the right server depending on the environment (dev, stage, or prod).

The Pre-Export Method is called before the project is being exported by the Unity Editor, and the Post-Export Method is called after.

Now you just have to use the right method that’ll suit your needs.

How to improve Unity Cloud Builds ?

Although Unity Cloud Build is great, I think it still requires some important features to several really tedious tasks such as deploying your game on the Apple and Google stores. (at the date we are writing this article at, Unity just started to offer auto deploy, but only for Xiaomi store). It would be great to have GGP and iOS deploy system just like the Xiaomi one.

The other things to improve is to offer a free tier for everyone to try Unity Cloud Build. I’m pretty sure Unity will convert more if people could use UCB as freemium service. (it might be very limited, but it still would be useful for very small indie devs).

I hope this article helped you out with this useful but sometimes ridiculously complicated tool. If you have any questions or comments, ask away! 🙂

In the meantime don’t forget to check out our devlogs and to sign up for the beta of our game :

Article by Anton Monjon