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
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.
- 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
- 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"
- 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>[...]
- 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
.
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
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
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