Note: This project is a "fork" of https://gitlab.com/gableroux/unity3d-gitlab-ci-example. More information available there.
This project is a PoC to run unity3d tests and builds inside a CI using gableroux/unity3d docker image. It currently creates builds for Windows, Linux, MacOS and webgl. The webgl build is published and accessible via the public artifact folder of your webgl job! This repository is hosted on multiple remotes to provide examples:
Table of Contents generated with DocToc
- Getting started
- Points of interest
- How to activate
- How to add build targets
- How to run scripts manually
- Shameless plug
- License
If you don't have a Unity project yet:
- Fork this project from github or gitlab
- Update the readme and remove undesired CI configurations
- Follow How to activate instructions
- Configure your CI
If you already have your own project:
- Copy desired CI file
- Update the Unity version according to your project version in the CI file. All versions are available at gableroux/unity3d docker image
- Copy build script (make sure you use the same path as original project, it must be in an
Editor
folder) - Follow How to activate instructions
- Configure your CI
This is probably what you're looking for.
Script passed to the unity3d command line as argument to create builds
- See
BuildScript.cs
This project will only cover Circle-CI. If you need more information on the gitlab and Travis implementations, go to https://gitlab.com/gableroux/unity3d-gitlab-ci-example
You'll first need to run this locally. All you need is docker installed on your machine.
-
Clone this project
-
Pull the docker image and run bash inside, passing unity username and password to env
hint: you should write this to a shell script and execute the shell script so you don't have your credentials stored in your bash history. Also make sure you use your Unity3d email address for
UNITY_USERNAME
env var.UNITY_VERSION=2018.4.3f1 docker run -it --rm \ -e "[email protected]" \ -e "UNITY_PASSWORD=example_password" \ -e "TEST_PLATFORM=linux" \ -e "WORKDIR=/root/project" \ -v "$(pwd):/root/project" \ gableroux/unity3d:$UNITY_VERSION \ bash
-
In Unity docker container's bash, run once like this, it will try to activate
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \ /opt/Unity/Editor/Unity \ -logFile \ -batchmode \ -username "$UNITY_USERNAME" -password "$UNITY_PASSWORD"
-
Wait for output that looks like this:
LICENSE SYSTEM [2017723 8:6:38] Posting <?xml version="1.0" encoding="UTF-8"?><root><SystemInfo><IsoCode>en</IsoCode><UserName>[...]
If you get the following error:
Can't activate unity: No sufficient permissions while processing request HTTP error code 401
Make sure your credentials are valid. You may try to disable 2FA in your account and try again. Once done, you should enable 2FA again for security reasons. See #11 for more details.
-
Copy xml content and save as
unity3d.alf
-
Open https://license.unity3d.com/manual and answer questions
-
Upload
unity3d.alf
for manual activation -
Download
Unity_v2018.x.ulf
-
Copy the content of
Unity_v2018.x.ulf
license file to your CI's environment variableUNITY_LICENSE_CONTENT
. Note: if you are doing this on windows, chances are the line endings will be wrong as explained here. Luckily for you,./circleci/config.yml
solves this by removing\r
character from the env variable so you'll be alright./circleci/config.yml
will then place theUNITY_LICENSE_CONTENT
to the right place before running tests or creating the builds.
Supported build targets can be found here
You can execute the local scripts and specify the path of your Unity executable using UNITY_EXECUTABLE
. You may try this in your project before you setup the whole CI so you confirm it works with your current unity version 👍
UNITY_EXECUTABLE="/Applications/Unity/Hub/Editor/2018.3.4f1/Unity.app/Contents/MacOS/Unity" \
./local_test.sh
UNITY_EXECUTABLE="/Applications/Unity/Hub/Editor/2018.3.4f1/Unity.app/Contents/MacOS/Unity" \
./local_build.sh
Gabriel Lebreton and I made this for free as a gift to the video game community so if this tool helped you, I would be very happy if you'd like to support me, support Totema Studio on Patreon: 🍻
MIT © Raphaël Côté