Skip to content

Run Unity 3D unit test code headless inside of Docker

License

Notifications You must be signed in to change notification settings

wtanaka/docker-unity3d

Repository files navigation

Unity3d docker image

Docker Stars Docker Pulls Docker Automated build Image Version

About this image

This docker image was based on GitLab CI with Unity3D in Docker and Unity3d docker image for running commands in CI such as gitlab-ci.

Linux Unity3d builds are taken from Unity on Linux: Release Notes and Known Issues

Things to consider

This docker image runs in a terminal so you don't have access to the UI. This docker image is intended to run unity commands with the command line. You can use it for running tests and creating builds.

Usage

Activate

  1. Pull the docker image and run it
UNITY_VERSION=2018.3.0f2
[email protected]
UNITY_PASSWORD=yourPassword
docker run -it --rm \
  -e "HOSTUID=`id -u`" \
  -e "HOSTGID=`id -g`" \
  -e "UNITY_USERNAME=$UNITY_USERNAME" \
  -e "UNITY_PASSWORD=$UNITY_PASSWORD" \
  -e "WORKDIR=/work" \
  -v "$(pwd):/work" \
  wtanaka/unity3d:"$UNITY_VERSION" \
  bash
  1. Run this to try to activate Unity
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
/opt/Unity/Editor/Unity \
-logFile \
-batchmode \
-username "$UNITY_USERNAME" -password "$UNITY_PASSWORD"
  1. 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>[...]
  1. Copy xml content and save as unity3d.alf
  2. Open https://license.unity3d.com/manual and answer questions
  3. Upload unity3d.alf for manual activation
  4. Download Unity_v2018.x.ulf
  5. Copy the content of Unity_v2018.x.ulf license file to your CI's environment variable UNITY_LICENSE_CONTENT.

Running play mode tests

UNITY_LICENSE_CONTENT="`cat Unity_v2018.x.ulf`"
export UNITY_LICENSE_CONTENT
UNITY_VERSION=2018.3.0f2
export UNITY_VERSION
docker run -it --rm \
  -e "HOSTUID=`id -u`" \
  -e "HOSTGID=`id -g`" \
  -e "TEST_PLATFORM=playmode" \
  -e UNITY_LICENSE_CONTENT \
  -e "WORKDIR=/work" \
  -v "$(pwd):/work" \
  wtanaka/unity3d:"$UNITY_VERSION" \
  /xvfb_runtests.sh

Running edit mode tests

UNITY_LICENSE_CONTENT="`cat Unity_v2018.x.ulf`"
export UNITY_LICENSE_CONTENT
UNITY_VERSION=2018.3.0f2
export UNITY_VERSION
docker run -it --rm \
  -e "HOSTUID=`id -u`" \
  -e "HOSTGID=`id -g`" \
  -e "TEST_PLATFORM=editmode" \
  -e UNITY_LICENSE_CONTENT \
  -e "WORKDIR=/work" \
  -v "$(pwd):/work" \
  wtanaka/unity3d:"$UNITY_VERSION" \
  /xvfb_runtests.sh

Building

UNITY_LICENSE_CONTENT="`cat Unity_v2018.x.ulf`"
export UNITY_LICENSE_CONTENT
UNITY_VERSION=2018.3.0f2
export UNITY_VERSION
docker run -it --rm \
  -e "HOSTUID=`id -u`" \
  -e "HOSTGID=`id -g`" \
  -e "TEST_PLATFORM=playmode" \
  -e UNITY_LICENSE_CONTENT \
  -e "WORKDIR=/work" \
  -v "$(pwd):/work" \
  wtanaka/unity3d:"$UNITY_VERSION" \
  /opt/Unity/Editor/Unity \
  -projectPath . \
  -quit -batchmode -nographics \
  -buildTarget WebGL \
  -customBuildTarget WebGL \
  -customBuildName TheBuildName \
  -customBuildPath TheBuild \
  -customBuildOptions AcceptExternalModificationsToPlayer \
  -executeMethod BuildCommand.PerformBuild \
  -logFile

License

MIT © Gabriel Le Breton

About

Run Unity 3D unit test code headless inside of Docker

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published