Unity
Your Unity License
Section titled “Your Unity License”Your Unity License is required to do some Git CI. To find your license, search your disc for a file called Unity_lic.ulf. If you can’t find one, look for any .ulf files that might be it. Usually, license files are found in C:\ProgramData\Unity. If there is one, great! If not,
-
Open Unity Hub
-
Click ‘Licenses’ on the list of tabs on the left
-
Click ’+ Add License’
-
Click ‘Get a free personal license’, even if you already have one. If you already have one, it won’t override your old one.
-
Search for
Unity_lic.ulfagain
If you’re on a computer with multiple users, you should delete your license file.
If you need the license for a secret for a GitHub Action, copy the entire contents of the file into the secret.
GitHub CI/CD
Section titled “GitHub CI/CD”GitHub has support for a continuous development/continuous deployment workflow. Unity has support for building and running unit tests.
-
Create
.ymlGitHub Action scripts inDirectoryProject root
- .gitignore
Directory.github This folder may be hidden
Directoryworkflows
- github-action.yml
DirectoryAssets/
- …
DirectoryLibrary/
- …
- …
-
Follow the steps above to find your Unity License
-
Navigate to your GitHub repository’s action secrets found in
Settings -> Secrets and Variables -> Actions -
Add a new action secret by clicking ‘New Repository Secret’. For these actions to work, you need three, named the following:
UNITY_EMAIL,UNITY_PASSWORD, andUNITY_LICENSE. The value of the first (what you put in the value field) is the email account associated with your Unity account. The second is the password to your Unity account, and the third is the entire contents of the license file (.ulf or .alf, depending if you have Personal or Pro).
Documentation for GitHub actions can be found here.
The following actions will trigger whenever you make a pull request to main (or commit to a branch that’s making a pull request to main). Replace UNITY_VERSION_HERE with your project’s Unity version and TARGET_PLATFORM_HERE with the associated tag for your build type. Find the list of build types in Unity’s Documentation. Find more information about Game CI (the source of the Docker images that these tests use to run Unity) here, and learn more about Docker here!
name: Unity Build
on: pull_request: branches: [ main ]
jobs: build: name: Build for Windows runs-on: ubuntu-latest
steps: - name: Free Disk Space uses: jlumbroso/free-disk-space@v1.3.1 with: android: true dotnet: false haskell: true large-packages: true
- name: Checkout uses: actions/checkout@v4
- name: Cache Library uses: actions/cache@v4 with: path: | Library obj key: UnityBuildCache-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} restore-keys: | UnityBuildCache-
- name: Build Project uses: game-ci/unity-builder@v4 env: UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} with: unityVersion: UNITY_VERSION_HERE targetPlatform: TARGET_PLATFORM_HERE # (StandaloneWindows64 for a Windows Build)
- name: Upload Build uses: actions/upload-artifact@v4 with: name: Build path: buildname: Unity Build
on: pull_request: branches: [ main ]
jobs: build: name: Run Unit Tests runs-on: ubuntu-latest
steps: - name: Free Disk Space uses: jlumbroso/free-disk-space@v1.3.1 with: android: true dotnet: false haskell: true large-packages: true
- name: Checkout uses: actions/checkout@v4
- name: Cache Library uses: actions/cache@v4 with: path: | Library obj key: UnityTestsCache-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} restore-keys: | UnityTestsCache-
- name: Play Mode Tests uses: game-ci/unity-test-runner@v4 env: UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} with: testMode: PlayMode customParameters: -quit -batchmode -nographics
- name: Edit Mode Tests uses: game-ci/unity-test-runner@v4 env: UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} with: testMode: EditMode customParameters: -quit -batchmode -nographics