Explore the Unity CLI commands, options, output formats, and exit codes you can use to install and manage Unity Editors and modules from a terminal.
阅读时间11 分钟最后更新于 1 天前
注意
The Unity CLI is experimental.
Find the commands and options available in the Unity CLI. For installation and common task instructions, refer to Use the Unity CLI.
To use the Unity CLI to control the Unity Editor, install and set up the Unity Pipeline package. For an example of how you can use the Unity CLI with Unity Pipeline, refer to the Unity CLI introduction video.Run
unity --help
to check the authoritative command list for your installed version, including any commands not yet covered on this page.
is the authoritative source for flags in your installed version. This page covers the main commands. Your release might add flags or commands that appear only in
--help
.
Update the CLI
Use the built-in self-update command to install the latest CLI release:
unity upgrade
Install an Editor
Install a Unity Editor version, optionally with modules.
unity install [version] [options]
The
version
argument is positional and optional:
On an interactive terminal, omitting the version opens an interactive prompt.
On a non-interactive terminal (for example, a CI pipeline), omitting the version is an error.
Version aliases
Alias
Resolves to
latest
The newest available Editor release.
lts
The newest long-term support release.
default
The version configured as your default in the Unity CLI.
6
,
6.5
,
2022
, and similar
The newest release within that major or minor stream.
Install options
Refer to
unity install --help
for the complete list.
Option
Usage
Description
-c, --changeset <hash>
-c 9b001d489a54
Changeset for the chosen Editor, required when the version isn't in the release list.
-m, --module <id>
-m android
or
-m ios webgl
Module IDs to install alongside the Editor. Accepts multiple values.
--cm
,
--childModules
--cm
Also install child modules of each selected module (for example, Android SDK & NDK under
android
).
-a, --architecture <arch>
-a arm64
or
-a x86_64
macOS only. Selects between Apple silicon and Intel builds.
Authentication or authorization failure, such as a rejected sign-in or an expired session.
4
Configuration required: the arguments are valid, but a required preference or context isn't set.
6
The command's primary operation failed, for example an Editor install failed, tests failed, or the Editor exited with an error.
130
The command was interrupted with Ctrl+C (
SIGINT
).
143
The command was terminated with
SIGTERM
, for example by
kill
or a CI runner timeout.
Environment variables
Global CLI options have environment variable equivalents, and some behaviors are controlled only through the environment. A command-line flag takes precedence over its environment variable.
Variable
Effect
UNITY_FORMAT
Default output format (
human
,
json
,
tsv
, or
ndjson
).
HUB_FORMAT
remains supported as an alias.
UNITY_QUIET
Suppress non-essential output, like
--quiet
.
UNITY_NO_BANNER
Suppress the Unity banner, like
--no-banner
.
UNITY_NON_INTERACTIVE
Disable interactive prompts, like
--non-interactive
.
UNITY_PROJECT_PATH
Default Unity project path for commands that accept
--project-path
.
UNITY_CLOUD_ORG
Default Unity Cloud organization for commands that accept
--cloud-org
.
UNITY_PROXY
Proxy server URL, like
--proxy
.
UNITY_LOG_PROXY
Log one redacted entry per outbound request for proxy troubleshooting, like
--log-proxy
.
UNITY_INSTALL_RETRIES
Number of retries for module downloads that fail intermittently, like
--retries
.
0
disables retries.
UNITY_NO_ELEVATE
Windows only. Skip the elevated (UAC) install helper, like
--no-elevate
.
UNITY_NO_UPDATE_CHECK
Disable the background check for CLI updates.
UNITY_NO_CRASH_REPORT
Disable anonymous crash and error reporting.
UNITY_NO_CONSENT_PROMPT
Suppress the one-time first-run analytics consent prompt without recording a choice.
UNITY_SERVICE_ACCOUNT_ID
,
UNITY_SERVICE_ACCOUNT_SECRET
Authenticate as a Unity service account for unattended workflows. Set both.
Progress output
Long-running commands (such as
install
) render animated progress bars on an interactive terminal and a static summary when complete. Progress output is for human readers. Don't parse it in scripts. For a machine-readable result, use
--format json
; to also stream machine-readable progress updates while the command runs, use
--format ndjson
, which emits typed progress frames followed by a final result frame.
Log locations
The CLI writes its own log file,
cli-log.json
, in the shared Unity Hub logs directory. Read and follow it with
unity logs
, or include it in a diagnostic snapshot with
unity doctor
.
Platform
Path
Windows
%UserProfile%\AppData\Roaming\UnityHub\logs
macOS
~/Library/Application Support/UnityHub/logs
Linux
~/.config/UnityHub/logs
You can also open the log folder from the Hub: Account > Help and Support > Logs.
Migrate from the Hub CLI
If you have scripts targeting the CLI embedded in the Unity Hub desktop application (invoked with
-- --headless
), the following tables summarize the behavioral and syntactic differences. For full Hub CLI syntax, refer to Hub CLI reference.
Invocation
Hub CLI
Unity CLI
How to run
"Unity Hub.exe" -- --headless <command>
unity <command>
Dependency
Requires the full Unity Hub desktop application.
Standalone binary; no Hub installation required.
Command and flag changes
Area
Hub CLI
Unity CLI
install
version
--version
/
-v <version>
(required flag)
[version]
(optional positional argument)
install-modules
editor version
--version
/
-v <version>
(required)
-e, --editor-version <version>
(optional)
install-modules
module
--module
/
-m <id>
(required)
-m, --module <id>
(optional)
editors
add local Editor
editors --add <path>
(flag)
editors add <path...>
(command; accepts multiple paths)
-v
on
install
Editor version
Reserved.
-V
prints the CLI version.
help
command
Platform-specific help text files
Replaced by
--help
on every command.
Output and errors
Area
Hub CLI
Unity CLI
Default output
Plain text, always
human
on an interactive terminal;
tsv
when piped
Structured output
--json
per command (where supported)
Global
--format json
(
--json
kept for compatibility)
Errors
Written to
stdout
Written to
stderr
(JSON errors:
{"error": "..."}
on
stderr
)
Progress
Plain text lines, for example
downloading 23.50%
Animated progress bar; static summary on completion
Exit codes
0
success,
1
error
Differentiated codes for usage, auth, and command failures. Refer to Exit codes.
Removed global flags
These Hub CLI flags have no equivalent in the Unity CLI:
--headless
,
--errors
,
--silent
,
--logLevel
/
-l
,
--bugReporter
,
--debugMode
,
--inspect
,
--userEmail
,
--theme
,
--editorLicense
,
--servicesUrlInterval
,
--cloudEnvironment
.
New commands
The Unity CLI adds many commands not in the Hub CLI, including
. Refer to the Commands tables for the full list. The path shorthand
unity ./MyProject
is equivalent to
unity open ./MyProject
.
Impact summary
重要
Review existing scripts and continuous integration (CI) pipelines before switching. The following items describe the areas most likely to require changes.
High: scripts that fail without updates
Replace
-- --headless
invocations with
unity
.
Replace
install -v <version>
with
install <version>
(positional).
Replace
install-modules --version
/
-v
with
--editor-version
/
-e
.
Replace
editors --add
with
editors add
.
Medium: behavior changes that can produce wrong results
Piped
stdout
defaults to TSV, not plain text.
Errors go to
stderr
, not
stdout
.
Progress output format changed. Don't parse it.
Low: additive changes that don't break existing usage