unity-build-pipeline
它能做什么
该技能指导智能体把 Unity 游戏打包成可在所选平台上运行的构建版本。适合为测试或发布做准备的开发者。
适用场景
- ✓当你在设置 Unity 构建中包含哪些场景时。
- ✓当你需要在 Mono 和 IL2CPP 脚本后端之间做选择,或想减小构建体积时。
- ✓当你需要通过脚本或 CI 系统自动运行 Unity 构建时。
技能链接
https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/unity/unity-build-pipeline/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我为 Unity 游戏制作一个 Windows 版本,只包含我实际使用的场景。”
每周 5 个新技能,1 分钟读完。
工作原理
该技能讲解如何设置场景列表和平台目标,选择脚本后端和裁剪选项,并通过脚本编写构建,使其无需打开编辑器即可运行。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Unity Build Pipeline
Configure, script, and automate Unity 6.3 LTS player builds: scenes, platform target, scripting backend, stripping, and headless/CI builds. Targets Unity 6.3 LTS (6000.3).
When to use
- Use when setting up Build Settings/Profiles, choosing a platform and scripting backend
(Mono vs IL2CPP), reducing build size with managed stripping, scripting a repeatable build
with
BuildPipeline.BuildPlayer, or wiring a CI/headless build. - Use when the project has
ProjectSettings/EditorBuildSettings.assetor a CI build script.
When not to use: authoring a CI service config end-to-end is DevOps; this skill covers
the Unity-side build API and settings. Console/platform certification specifics are
platform-NDA territory. Storefront submission → steam-publish / itch-publish.
Core workflow
- List the scenes to build (File → Build Profiles → Scene List, or
EditorBuildSettings.scenes). Only listed, enabled scenes ship; scene 0 is the start scene. A Build Profile asset can carry its own Scene List (Add Settings → Scene List); when it does, that profile builds its list, not the global one. - Pick the platform target and switch the active build target if needed
(
BuildTarget/EditorUserBuildSettings). In batch mode, pass-buildTarget <name>on the command line instead:SwitchActiveBuildTargetis not available there. - Choose the scripting backend (Player Settings): Mono (fast iteration, desktop) vs IL2CPP (AOT C++; required for many platforms, better perf, harder to reverse). IL2CPP needs the platform's C++ toolchain installed. (Forward note: Unity is developing a CoreCLR backend as a modern .NET runtime successor to Mono, but in the Unity 6.7 beta it is still experimental, desktop-only, and documented as not suitable for production — so for 6.3 LTS the choice stays Mono vs IL2CPP.)
- Tune size/perf: set Managed Stripping Level (Disabled → Minimal → Low → Medium → High)
and protect reflection-only code with a
link.xml. Set Quality Settings per platform. - Script the build with
BuildPipeline.BuildPlayer(BuildPlayerOptions)and inspect the returnedBuildReport— a non-Succeededresult must fail your pipeline. - Run headless for CI with
-batchmode -quit -executeMethod, and check the exit code. - Verify the actual output runs (launch the player), not just that the build returned without throwing.
Patterns
1. Scripted build with a result check
using UnityEditor;
using UnityEditor.Build.Reporting;
using UnityEngine;
public static class BuildScript
{
[MenuItem("Build/Windows x64")]
public static void BuildWindows()
{
var options = new BuildPlayerOptions
{
scenes = new[] { "Assets/Scenes/Main.unity", "Assets/Scenes/Level1.unity" },
locationPathName = "Builds/Windows/Game.exe",
target = BuildTarget.StandaloneWindows64,
options = BuildOptions.None, // add BuildOptions.Development for a dev build
};
BuildReport report = BuildPipeline.BuildPlayer(options);
BuildSummary summary = report.summary;
if (summary.result != BuildResult.Succeeded)
throw new System.Exception($"Build failed: {summary.totalErrors} errors");
Debug.Log($"Build OK: {summary.totalSize} bytes in {summary.totalTime}");
}
}
2. Headless / CI invocation
# Exit code is 0 on success; -quit ensures the editor closes; -nographics for build servers.
# -buildTarget makes the Editor start on that platform, so scripts compile with its defines.
Unity -batchmode -quit -nographics \
-projectPath "/path/to/Project" \
-buildTarget win64 \
-executeMethod BuildScript.BuildWindows \
-logFile -
3. Build a saved Build Profile
using UnityEditor;
using UnityEditor.Build.Profile;
using UnityEditor.Build.Reporting;
public static class ProfileBuild
{
[MenuItem("Build/Windows Release Profile")]
public static void Build()
{
var profile = AssetDatabase.LoadAssetAtPath<BuildProfile>(
"Assets/Settings/Build Profiles/WindowsRelease.asset");
var options = new BuildPlayerWithProfileOptions
{
buildProfile = profile, // platform, scene list, defines from the asset
locationPathName = "Builds/Windows/Game.exe",
options = BuildOptions.None,
};
常见问题
什么是 IL2CPP?
IL2CPP 是 Unity 的两种脚本后端之一,该技能将它与 Mono 进行了比较。
它会把游戏发布到商店吗?
不会。提交到商店由另外的技能负责。
它涵盖主机认证吗?
不涵盖。主机认证的细节因平台而异,不在本技能范围之内。
详情
作者的原始描述
Build and ship Unity 6.3 LTS players: build settings and scenes, player/quality settings, the IL2CPP vs Mono scripting backend, managed code stripping, scripted BuildPipeline.BuildPlayer, and CI/headless builds. Use when configuring or automating a build, choosing a scripting backend, shrinking build size, or when the user mentions Unity build, player settings, IL2CPP, code stripping, or Addressables.
热度
- GitHub 星标
- 6.6k
- 排名
- #13845
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/28
评论
- …