Skip to content

Commit 808549f

Browse files
committed
Completed merge of inx internal fixes.
1 parent e137f1d commit 808549f

346 files changed

Lines changed: 335595 additions & 287 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/bin/bash
2+
#---------------------------------------------------------------
3+
# Copyright (C) 2025, inx limited, UK.
4+
# All Rights Reserved.
5+
# You may use, distribute and modify this code under the terms
6+
# of the LGPLv3 license. You should have received a copy of the
7+
# LGPLv3 (GNU LESSER GENERAL PUBLIC LICENSE Version 3) license
8+
# with this file. If not, please visit
9+
# <https://www.gnu.org/licenses/lgpl-3.0.txt>
10+
#---------------------------------------------------------------
11+
#
12+
# Host Unity SDK Installer
13+
#
14+
# Installs Unity Hub (if needed) then prints step-by-step instructions
15+
# for installing Unity 2019.4.40f1 with Android support via the Hub GUI.
16+
#
17+
# The Unity Hub headless CLI is unreliable (hangs waiting for the Hub
18+
# daemon), so the editor install is done manually through the GUI.
19+
#
20+
# Target install path expected by the build system:
21+
# /opt/unity3d/2019.4.40f1/Editor/Unity
22+
#
23+
# After following the steps below, make targetenv_unity_export will find
24+
# Unity automatically.
25+
#
26+
# Usage:
27+
# ./scripts/build-deploy/unity/install-unity-host.sh
28+
#
29+
# Requirements:
30+
# - Ubuntu 20.04 / 22.04 (or compatible Debian-based distro)
31+
# - sudo access
32+
# - Internet access
33+
34+
set -e
35+
36+
UNITY_VERSION="2022.3.62f3"
37+
UNITY_CHANGESET="" # look up at https://unity.com/releases/editor/whats-new/2022.3.62
38+
UNITY_INSTALL_ROOT="/opt/unity3d"
39+
UNITY_EDITOR_PATH="${UNITY_INSTALL_ROOT}/${UNITY_VERSION}/Editor"
40+
41+
echo "======================================================================"
42+
echo " Unity Host SDK Installer"
43+
echo " Version : ${UNITY_VERSION}"
44+
echo " Install : ${UNITY_INSTALL_ROOT}/${UNITY_VERSION}/"
45+
echo "======================================================================"
46+
echo ""
47+
48+
if [ -x "${UNITY_EDITOR_PATH}/Unity" ]; then
49+
echo "Unity ${UNITY_VERSION} is already installed at ${UNITY_EDITOR_PATH}."
50+
echo "Nothing to do."
51+
exit 0
52+
fi
53+
54+
# ── Step 1: install Unity Hub via APT (if not already present) ───────────
55+
if ! command -v unityhub &>/dev/null; then
56+
echo "Step 1: Installing Unity Hub ..."
57+
wget -qO - https://hub.unity3d.com/linux/keys/public | gpg --dearmor | sudo tee /usr/share/keyrings/Unity_Technologies_ApS.gpg >/dev/null
58+
echo "deb [signed-by=/usr/share/keyrings/Unity_Technologies_ApS.gpg] https://hub.unity3d.com/linux/repos/deb stable main" | sudo tee /etc/apt/sources.list.d/unityhub.list
59+
sudo apt-get update -qq
60+
sudo apt-get install -y unityhub
61+
echo "Unity Hub installed."
62+
else
63+
echo "Step 1: Unity Hub already installed. Skipping."
64+
fi
65+
66+
# ── Step 2: create /opt/unity3d with correct permissions ─────────────────
67+
echo ""
68+
echo "Step 2: Creating ${UNITY_INSTALL_ROOT} ..."
69+
sudo mkdir -p "${UNITY_INSTALL_ROOT}"
70+
sudo chown "$(id -u):$(id -g)" "${UNITY_INSTALL_ROOT}"
71+
echo "Done — ${UNITY_INSTALL_ROOT} is writable by ${USER}."
72+
73+
# ── Step 3: manual instructions for the Hub GUI ──────────────────────────
74+
echo ""
75+
echo "======================================================================"
76+
echo " Step 3 — Install Unity ${UNITY_VERSION} via Unity Hub GUI"
77+
echo ""
78+
echo " The Unity Hub headless CLI is unreliable so this step is manual."
79+
echo ""
80+
echo " 1. Launch Unity Hub:"
81+
echo " unityhub"
82+
echo ""
83+
echo " 2. Sign in (or create a free account at https://id.unity.com)"
84+
echo ""
85+
echo " 3. Activate a Personal license:"
86+
echo " Preferences -> Licenses -> Add -> Get a free Personal license"
87+
echo ""
88+
echo " 4. Install the editor:"
89+
echo " Installs -> Install Editor -> Archive tab"
90+
echo " -> find ${UNITY_VERSION} (LTS) -> Install"
91+
echo ""
92+
echo " When prompted for modules, tick:"
93+
echo " [x] Android Build Support"
94+
echo " [x] Android SDK & NDK Tools"
95+
echo " [x] OpenJDK"
96+
echo ""
97+
echo " 5. IMPORTANT — change the install location to ${UNITY_INSTALL_ROOT}:"
98+
echo " Preferences -> Installs -> Default install location"
99+
echo " -> set to: ${UNITY_INSTALL_ROOT}"
100+
echo " (Do this BEFORE clicking Install in step 4)"
101+
echo ""
102+
echo " 6. Once installed, verify the build system can find it:"
103+
echo " ls ${UNITY_EDITOR_PATH}/Unity"
104+
echo ""
105+
echo " Then run make targetenv_unity_export as normal."
106+
echo "======================================================================"
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
#!/bin/bash
2+
#---------------------------------------------------------------
3+
# Copyright (C) 2025, inx limited, UK.
4+
# All Rights Reserved.
5+
# You may use, distribute and modify this code under the terms
6+
# of the LGPLv3 license. You should have received a copy of the
7+
# LGPLv3 (GNU LESSER GENERAL PUBLIC LICENSE Version 3) license
8+
# with this file. If not, please visit
9+
# <https://www.gnu.org/licenses/lgpl-3.0.txt>
10+
#---------------------------------------------------------------
11+
#
12+
# Unity License Setup — GameCI Docker method
13+
#
14+
# Activates a Unity Personal license online using your Unity account
15+
# credentials, then saves the resulting license file so that
16+
# make targetenv_unity_export_docker can run headless builds using the
17+
# unityci/editor Docker image (no local Unity Hub install needed).
18+
#
19+
# Run this ONCE on any machine that will build Unity targets.
20+
# Add the export line printed at the end to ~/.bashrc (or your CI
21+
# secrets store).
22+
#
23+
# Usage:
24+
# ./scripts/build-deploy/unity/setup-unity-license.sh
25+
#
26+
# Or with credentials inline (non-interactive, e.g. for CI setup):
27+
# UNITY_EMAIL=you@example.com UNITY_PASSWORD=secret \
28+
# ./scripts/build-deploy/unity/setup-unity-license.sh
29+
#
30+
# Requirements:
31+
# - Docker installed and the current user in the docker group
32+
# - A free Unity account at https://id.unity.com
33+
# - Internet access from the Docker container for online activation
34+
# - 2FA must be disabled on the Unity account used here
35+
#
36+
# Unity version targeted by this repo:
37+
UNITY_VERSION="2022.3.62f3"
38+
UNITY_DOCKER_IMAGE="unityci/editor:ubuntu-${UNITY_VERSION}-android-3.1.0"
39+
ACTIVATION_DIR="/tmp/unity-activation"
40+
CONTAINER_NAME="unity-license-activation-$$"
41+
42+
set -e
43+
44+
echo "======================================================================"
45+
echo " Unity License Setup for eRT Unity builds"
46+
echo " Unity version : $UNITY_VERSION"
47+
echo " Docker image : $UNITY_DOCKER_IMAGE"
48+
echo "======================================================================"
49+
echo ""
50+
echo " NOTE: Unity no longer supports manual offline activation for Personal"
51+
echo " licenses. This script activates online using your Unity account."
52+
echo " 2FA must be disabled on the account used here."
53+
echo ""
54+
55+
# ── Prompt for credentials if not already set ────────────────────────────
56+
if [ -z "$UNITY_EMAIL" ]; then
57+
read -rp "Unity account email: " UNITY_EMAIL
58+
fi
59+
if [ -z "$UNITY_PASSWORD" ]; then
60+
read -rsp "Unity account password: " UNITY_PASSWORD
61+
echo ""
62+
fi
63+
64+
if [ -z "$UNITY_EMAIL" ] || [ -z "$UNITY_PASSWORD" ]; then
65+
echo "ERROR: UNITY_EMAIL and UNITY_PASSWORD must be set."
66+
exit 1
67+
fi
68+
69+
mkdir -p "$ACTIVATION_DIR"
70+
71+
# Clean up any leftover container from a previous failed run
72+
docker rm "$CONTAINER_NAME" 2>/dev/null || true
73+
74+
# ── Activate online — use a named container so we can docker cp the result ──
75+
# We do NOT use --rm here so the container's filesystem survives for inspection.
76+
# -quit tells Unity to exit after activation rather than hanging.
77+
echo ""
78+
echo "Activating Unity Personal license online ..."
79+
80+
docker run --name "$CONTAINER_NAME" --privileged --network host \
81+
"${UNITY_DOCKER_IMAGE}" \
82+
/opt/unity/Editor/Unity \
83+
-quit -batchmode -nographics \
84+
-username "${UNITY_EMAIL}" \
85+
-password "${UNITY_PASSWORD}" \
86+
-logFile /dev/stdout || true
87+
88+
# ── Copy the license file out of the stopped container ───────────────────
89+
echo ""
90+
echo "Searching for license file in stopped container ..."
91+
92+
# Try the standard Linux path first, then search broadly if not found
93+
docker cp "${CONTAINER_NAME}:/root/.local/share/unity3d/Unity/." \
94+
"${ACTIVATION_DIR}/" 2>/dev/null || true
95+
96+
ULF_FILE=$(ls "${ACTIVATION_DIR}"/Unity_lic.ulf \
97+
"${ACTIVATION_DIR}"/Unity_v*.ulf 2>/dev/null | head -1)
98+
99+
if [ -z "$ULF_FILE" ]; then
100+
# Broad search: dump all .ulf files from anywhere in the container
101+
echo "Not found at standard path — searching entire container filesystem ..."
102+
FOUND_IN_CONTAINER=$(docker exec "$CONTAINER_NAME" \
103+
find / -name "*.ulf" 2>/dev/null | head -5 || true)
104+
if [ -n "$FOUND_IN_CONTAINER" ]; then
105+
echo "Found .ulf file(s) in container at:"
106+
echo "$FOUND_IN_CONTAINER"
107+
FIRST=$(echo "$FOUND_IN_CONTAINER" | head -1)
108+
docker cp "${CONTAINER_NAME}:${FIRST}" "${ACTIVATION_DIR}/"
109+
ULF_FILE="${ACTIVATION_DIR}/$(basename "$FIRST")"
110+
fi
111+
fi
112+
113+
docker rm "$CONTAINER_NAME" 2>/dev/null || true
114+
115+
if [ -z "$ULF_FILE" ]; then
116+
echo ""
117+
echo "======================================================================"
118+
echo "ERROR: No license file found."
119+
echo ""
120+
echo "Possible causes:"
121+
echo " - Wrong email or password"
122+
echo " - 2FA is enabled on the Unity account (disable it and retry)"
123+
echo " - Network not reachable from Docker container"
124+
echo " - Unity activation API changed for this version"
125+
echo ""
126+
echo "Check the Docker log output above for 'license' or 'error' messages."
127+
echo "======================================================================"
128+
exit 1
129+
fi
130+
131+
echo ""
132+
echo "License file saved to: $ULF_FILE"
133+
134+
# ── Print the export instruction ─────────────────────────────────────────
135+
echo ""
136+
echo "======================================================================"
137+
echo " License activation complete."
138+
echo ""
139+
echo " Add the following line to your ~/.bashrc so that"
140+
echo " make targetenv_unity_export_docker can use this license:"
141+
echo ""
142+
echo " export UNITY_LICENSE=\$(cat '${ULF_FILE}')"
143+
echo ""
144+
echo " To apply it in this shell session right now, run:"
145+
echo " export UNITY_LICENSE=\$(cat '${ULF_FILE}')"
146+
echo "======================================================================"

0 commit comments

Comments
 (0)