Unity CLI:从终端管理 Unity
The Unity CLI: manage Unity from your terminal

原始链接: https://unity.com/blog/meet-the-unity-cli

Unity CLI 是一款轻量级、自包含的二进制程序,旨在替代运行速度较慢的 Unity Hub 无头(headless)进程。它无需任何依赖,可通过简单的脚本安装,并即将支持标准的软件包管理器。 主要功能包括: * **简化管理**:通过直观的命令轻松安装特定的 Unity 版本和模块、管理身份验证以及解析项目编辑器。 * **适配自动化**:专为 CI/CD 流水线构建,CLI 提供结构化输出(JSON/TSV)、明确的退出代码,并支持非交互式(“无头”)环境。 * **高性能**:其原生架构确保了快速的启动时间,显著降低了自动化任务的开销。 无论您是在管理编辑器、配置模块还是运行无人值守的构建,Unity CLI 都能提供稳健的、以命令行优先的工作流程,无需人工干预或基于浏览器的身份验证。

抱歉。
相关文章

原文

What is the Unity CLI

The CLI ships as a single self-contained binary. There are no dependencies to install, and installation adds itself to your PATH: simply run it as unity, and update it in place with unity upgrade. Beyond editors and projects, it also handles modules and authentication, so a fresh machine needs nothing else.

Because it's a native binary, it starts quickly, whereas the old Unity Hub headless path (-- --headless) took noticeably longer. This gap adds up across the dozens of calls a script or agent makes per job.

Get started

Install it with your platform’s package manager:

# macOS or Linux
curl -fsSL https://public-cdn.cloud.unity3d.com/hub/prod/cli/install.sh | UNITY_CLI_CHANNEL=beta bash

# Windows
$env:UNITY_CLI_CHANNEL='beta'; irm https://public-cdn.cloud.unity3d.com/hub/prod/cli/install.ps1 | iex

(Note: Support for standard package managers like brew, winget and apt is coming soon. Refer to the CLI documentation for the latest.)

Explore what's available:

Installing an editor with the modules you need is a one-liner:

unity install 6000.2.10f1 -m android ios webgl

From there, commands read the way you'd expect: unity editors to see what's installed, unity open to launch a project with the right editor resolved, and unity auth login to sign in. Not sure which module IDs a version has? unity modules list 6000.2.10f1 has you covered.

Built for automation

The CLI was built to live inside automation, not just an interactive shell. Every command can emit structured output you can pipe straight into your tooling:

unity editors --format json
unity editors --format tsv

Errors go to stderr, results to stdout, and exit codes follow a simple contract (0 success, 1 error, 130 cancelled), so failures are easy to catch in a pipeline.

For unattended installs, skip every prompt:

unity install 6000.2.10f1 -m android ios --accept-eula --yes

On a headless build agent, it authenticates with a service account via environment variables. No browser, no manual step. And unity doctor diagnoses environment, credential, and configuration problems.

联系我们 contact @ memedata.com