Use the Unity command-line interface (CLI)
Install the Unity CLI standalone binary and use it to install Editors, add modules, and open projects from a terminal.
阅读时间9 分钟最后更新于 6 小时前
Use the Unity CLI to install Unity Editors, add modules, and manage projects from a terminal without the Unity Hub desktop application. The CLI is a standalone binary that works in CI pipelines, automation scripts, and terminal-first workflows.
The Unity CLI works well for:
- Continuous integration (CI) and build agents where installing the full Hub is undesirable.
- Scripting and automation that needs structured output (JSON or TSV) and predictable exit codes.
- Users who prefer a terminal-first workflow for everyday Hub tasks.
For command syntax, options, and flags, refer to Unity CLI reference. If you have existing scripts that use the Hub CLI's syntax, refer to Migrate from the Hub CLI for a comparison of syntax and behavior changes.
-- --headlessCompatibility
The Unity CLI is compatible with the following operating systems:
- Windows 10 21H1 or newer.
- Linux RHEL 9 and Ubuntu 22.04 and later. Requires glibc 2.34 or newer. Debian 11, CentOS 8, Amazon Linux 2 aren't supported.
- macOS 14 and newer.
Common Unity CLI tasks
The following commands cover the most common CLI tasks:
unity --help # Top-level helpunity install lts # Install the latest LTS Editorunity install-modules -e 6000.3.7f1 -m ios # Add the iOS moduleunity editors -i # List installed Editorsunity open ./MyProject # Open a projectunity shell # Run many commands in one interactive sessionunity doctor # Print a diagnostic snapshot
Install the Unity CLI
To install the Unity CLI:
- Open a terminal. On Windows, use PowerShell.
- Run the install script for your operating system.
curl -fsSL https://public-cdn.cloud.unity3d.com/hub/prod/cli/install.sh | UNITY_CLI_CHANNEL=beta bash
After the script completes, verify the CLI is available by running . If the command isn't found, add the install directory to your shell's or reopen your terminal.
unity --versionPATHOn Linux, the script installs the binary to , which is on by default on most distributions. Re-running the installer migrates an install from the previous location.
~/.local/bin/unityPATH~/.unityThe install script above is the recommended way to install the Unity CLI. It always installs the latest release, and keeps the CLI current after installation (refer to Update the Unity CLI). If you already manage command-line tools with a package manager, you can use one of the alternatives below:
unity self-update- Homebrew: update through that package manager instead of
unity self-update - Linux package repositories: update through that package manager instead of
unity self-update - winget: winget is the exception, it installs an MSIX package, so keeps working
unity self-update
Install with a package manager
On macOS and Linux, you can install the CLI with Homebrew instead of the install script, so Homebrew keeps it current:
brew install --cask unity-cli
The cask supports Apple silicon and Intel on macOS, and x64 and arm64 on Linux. On Linux, installing casks requires Homebrew 6.0 or later.
To update the CLI, run .
brew upgrade unity-cliUpdate the Unity CLI
To update the CLI to the latest release:
- Open a terminal.
- Run the self-update command:
unity self-update
The CLI replaces the current binary with the latest available release. The CLI also checks for updates in the background and prints a notice when a new release is available. To turn the check off, run .
unity config update-check offIf you installed the CLI with Homebrew or from the Linux package repositories, update it through that package manager instead. detects the package-managed install and shows the matching command. A winget install is the exception, since it's an MSIX package, continues to update it directly.
unity self-updateunity self-updateUpdate with a package manager
brew upgrade unity-cli
To see what the CLI resolved and which command updates your install, run:
unity diagnose update
Install a Unity Editor
To install a Unity Editor:
- Open a terminal.
- Run with the version you want. Use a version alias such as
unity installor a specific version string such aslts:6000.3.7f1
unity install ltsunity install 6000.3.7f1
The Editor downloads and installs to the configured install path.
To add modules at install time, use followed by one or more module IDs:
-munity install lts -m ios android webgl
For all options, version aliases, and module IDs, refer to Unity CLI reference.
Add modules to an installed Editor
To add modules to an Editor you already installed:
- Open a terminal.
- Run with
unity install-modulesfor the Editor version and-efor the module IDs:-m
unity install-modules -e 6000.3.7f1 -m android ios
The modules download and install for the specified Editor version.
For all options and module IDs, refer to Unity CLI reference.
Open a project
To open a Unity project:
- Open a terminal.
- Run with the path to the project:
unity open
unity open ./MyProject
Unity opens the project in the Editor version specified in the project's settings.
You can omit the keyword when the first argument is a path:
openunity ./MyProject
Sign in
To sign in to your Unity account:
- Open a terminal.
- Run the login command, which opens a browser-based sign-in flow:
unity auth login
The CLI stores your session so you can use other commands without signing in again.
To check whether you're signed in, run . For all auth commands, refer to Unity CLI reference.
unity auth statusSign in as a service account
For unattended workflows such as CI pipelines and build agents, you can authenticate with a service account. This is the same service account type used to sign into other Unity services, it isn't specific to the CLI. To learn how to create a service account, refer to Service accounts.
To sign in automatically through the Unity CLI, set the and environment variables to the account's key ID and secret key. For the full list of environment variables, refer to Unity CLI reference.
UNITY_SERVICE_ACCOUNT_IDUNITY_SERVICE_ACCOUNT_SECRET