Skip to main content
Version: v1

Activation

There are a few methods available, if you're using gitlab-ci, the easiest method in the current documentation is using gitlab-ci.

Unity Personal

a. Using gitlab-ci

Once you've added all required files to your project (mainly .gitlab-ci.yml), there should be a manual step that can be triggered for activation.

  1. Visit your project's settings > CI/CD > Variables and add UNITY_USERNAME and UNITY_PASSWORD with your credentials. Make sure to use your Unity3d email address for UNITY_USERNAME.
  2. Push your first commit to your project and visit CI/CD Pipelines.
  3. Locate your latest job, there should be a play button, click on it and click get-activation-file
  4. Wait for the job to run and follow instructions in the console

b. Locally

All you need is docker installed on your machine.

  1. Clone this project

  2. 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=2020.1.11f1
    IMAGE=unityci/editor # https://hub.docker.com/r/unityci/editor
    IMAGE_VERSION=0.12 # https://github.com/game-ci/docker/releases
    DOCKER_IMAGE=$IMAGE:$UNITY_VERSION-base-$IMAGE_VERSION

    docker run -it --rm \
    -e "[email protected]" \
    -e "UNITY_PASSWORD=example_password" \
    -e "TEST_PLATFORM=linux" \
    -e "WORKDIR=/root/project" \
    -v "$(pwd):/root/project" \
    $DOCKER_IMAGE \
    bash

    If your password contains a !, you can escape it like this (example_pass!word):

    ...
    -e "UNITY_PASSWORD=example_pass"'!'"word" \
    ...
  3. In Unity docker container's bash, run once like this, it will try to activate

    xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
    unity-editor \
    -logFile /dev/stdout \
    -batchmode \
    -nographics \
    -username "$UNITY_USERNAME" -password "$UNITY_PASSWORD"
  4. 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.

  5. Copy xml content and save as unity3d.alf

  6. Open https://license.unity3d.com/manual and answer questions

  7. Upload unity3d.alf for manual activation

  8. Download Unity_v2018.x.ulf (Unity_v2019.x.ulf for 2019 versions)

  9. Copy the content of Unity_v2018.x.ulf license file to your CI's environment variable UNITY_LICENSE. Note: if you are doing this on Windows, chances are the line endings will be wrong as explained here. Luckily for you, .gitlab-ci.yml of the example project solves this by removing \r character from the ENV variable so you'll be alright .gitlab-ci.yml will then place the UNITY_LICENSE to the right place before running tests or creating the builds.

Unity Plus/Pro

  1. Clone this project

  2. 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=2020.1.11f1
    IMAGE=unityci/editor # https://hub.docker.com/r/unityci/editor
    IMAGE_VERSION=0.12 # https://github.com/game-ci/docker/releases
    DOCKER_IMAGE=$IMAGE:$UNITY_VERSION-base-$IMAGE_VERSION

    docker run -it --rm \
    -e "[email protected]" \
    -e "UNITY_PASSWORD=example_password" \
    -e "UNITY_SERIAL=AN-EXAM-PLE-SERIA-LKEY-1234" \
    -e "TEST_PLATFORM=linux" \
    -e "WORKDIR=/root/project" \
    -v "$(pwd):/root/project" \
    $DOCKER_IMAGE \
    bash
  3. In Unity docker container's bash, run once like this, it will try to activate

    xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
    unity-editor \
    -logFile /dev/stdout \
    -batchmode \
    -nographics \
    -username "$UNITY_USERNAME" -password "$UNITY_PASSWORD" -serial "$UNITY_SERIAL"
  4. Wait for the command to finish without errors

  5. Obtain the contents of the license file by running cat /root/.local/share/unity3d/Unity/Unity_lic.ulf

  6. Copy the content to your CI's environment variable UNITY_LICENSE. Note: if you are doing this on windows, chances are the line endings will be wrong as explained here. Luckily for you, .gitlab-ci.yml solves this by removing \r character from the env variable so you'll be alright .gitlab-ci.yml will then place the UNITY_LICENSE to the right place before running tests or creating the builds.