77 game-dev skills for AI coding agents — Godot, Unity, Unreal, Phaser, PixiJS, three.js, Bevy, pygame, LÖVE, Roblox. Portable SKILL.md Agent Skills (the format Anthropic launched as Claude Skills), with a router that loads the right skill for your engine and task. Runs in Claude Code, Cursor, Kiro, Codex, Copilot, Gemini CLI and more.
Python agent-skillsai-agentsantigravityawesome-listclaude-codeclinecodexcursorgame-devgame-developmentgamedevgemini-cligithub-copilotgodotkirooh-my-piskillsunityunrealwindsurf
fix(unity): build pipeline uses -buildTarget in batch mode, adds Build Profile builds
Kiro Crew704e9f65957d
diff --git a/skills/unity/unity-build-pipeline/SKILL.md b/skills/unity/unity-build-pipeline/SKILL.mdindex a1cd06a..5e7fa80 100644--- a/skills/unity/unity-build-pipeline/SKILL.md+++ b/skills/unity/unity-build-pipeline/SKILL.md@@ -26,16 +26,19 @@ platform-NDA territory. Storefront submission → `steam-publish` / `itch-publis## Core workflow-1. **List the scenes to build** (File → Build Profiles/Settings → Scene List, or+1. **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.2. **Pick the platform target** and switch the active build target if needed- (`BuildTarget` / `EditorUserBuildSettings`).+ (`BuildTarget` / `EditorUserBuildSettings`). In batch mode, pass `-buildTarget <name>` on+ the command line instead: `SwitchActiveBuildTarget` is not available there.3. **Choose the scripting backend** (Player Settings): **Mono** (fast iteration, desktop) vs**IL2CPP** (AOT C++; required for many platforms, better perf, harder to reverse). IL2CPPneeds the platform's C++ toolchain installed. (Forward note: Unity is developing a- **CoreCLR** backend as a modern .NET runtime successor to Mono, but it is *experimental*,- desktop-only, and not production-ready as of Unity 6.7 — so for 6.3 LTS the choice stays- Mono vs IL2CPP.)+ **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.)4. **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.5. **Script the build** with `BuildPipeline.BuildPlayer(BuildPlayerOptions)` and **inspect the@@ -80,13 +83,42 @@ public static class BuildScript```bash# 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. Protect stripped code with `link.xml`+### 3. Build a saved Build Profile++```csharp+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,+ };+ BuildReport report = BuildPipeline.BuildPlayer(options);+ if (report.summary.result != BuildResult.Succeeded)+ throw new System.Exception($"Build failed: {report.summary.totalErrors} errors");+ }+}+```++### 4. Protect stripped code with `link.xml````xml<!-- Assets/link.xml — keep types the linker can't see are used (reflection, JSON, plugins). -->@@ -105,20 +137,29 @@ Unity -batchmode -quit -nographics \reflection-only code. Lower the stripping level or add a `link.xml` preserve entry.- **Treating "BuildPlayer returned" as success** — always check `BuildReport.summary.result`;it can return with errors.-- **Addressables content is stale/missing** — Addressables (`com.unity.addressables`) need a- *separate* content build (Build → Addressables) and a profile pointing at the right load- path; a player build alone doesn't rebuild them.+- **Addressables content is stale/missing** — Addressables (`com.unity.addressables`) content+ is built by Build → Addressables or by `AddressableAssetSettings.BuildPlayerContent`. The+ **Build Addressables on Player Build** setting can do it during a player build, but when it+ is left at "Use global Settings" the result depends on each machine's Preferences — call the+ content build explicitly in CI, and check the profile's load path.+- **The build platform's code didn't compile in** — a scripted `BuildPlayer` for a target+ other than the active one keeps the active platform's `UNITY_*` defines, and define changes+ only apply after a domain reload. Switch platform first (in the Editor) or launch with+ `-buildTarget` (batch mode).+- **Build ignores scenes you added to the global list** — the Build Profile you build has its+ own Scene List. Edit that list; a profile without a Scene List uses the global one.- **Shipping a Development build** — `BuildOptions.Development` enables the profiler/debuggingand is slower; use `BuildOptions.None` for release.## References-- For a complete **multi-platform CI build script** (target switching, version stamping,- argument parsing, exit codes) and an Addressables content-build call, read- `references/ci-build-script.md`.-- Primary docs: `ScriptReference/BuildPipeline.BuildPlayer`, Unity Manual build sections- (player settings, managed code stripping). For the forward-looking CoreCLR backend, see the- experimental note at+- For a complete **multi-platform CI build script** (`-buildTarget` per platform, version+ stamping, argument parsing, exit codes), building a Build Profile from the command line, and+ an Addressables content-build call, read `references/ci-build-script.md`.+- Primary docs: `ScriptReference/BuildPipeline.BuildPlayer`, `ScriptReference/BuildPlayerWithProfileOptions`,+ the Manual pages "Editor command line arguments" and "Manage scenes in a build", and Unity+ Manual build sections (player settings, managed code stripping). For the forward-looking+ CoreCLR backend, see the experimental note at`https://docs.unity3d.com/6000.7/Documentation/Manual/scripting-backends-coreclr.html`.## Related skillsdiff --git a/skills/unity/unity-build-pipeline/references/ci-build-script.md b/skills/unity/unity-build-pipeline/references/ci-build-script.mdindex 24067a0..e52e731 100644--- a/skills/unity/unity-build-pipeline/references/ci-build-script.md+++ b/skills/unity/unity-build-pipeline/references/ci-build-script.md@@ -1,8 +1,16 @@# CI / headless build script (Unity 6.3 LTS)Depth for `unity-build-pipeline`: a reusable editor build script that takes command-line-arguments, switches platform, stamps a version, and returns a proper exit code. Verified-against `ScriptReference/BuildPipeline.BuildPlayer` and the editor command-line arguments.+arguments, stamps a version, and returns a proper exit code. Verified against+`ScriptReference/BuildPipeline.BuildPlayer`, `ScriptReference/EditorUserBuildSettings.SwitchActiveBuildTarget`+and the 6000.3 Manual page "Editor command line arguments".++**Pick the platform with Unity's own `-buildTarget` flag, not from inside the script.**+`EditorUserBuildSettings.SwitchActiveBuildTarget` is not available in batch mode: a platform+switch needs a script recompile, which cannot happen while your `-executeMethod` code runs.+`-buildTarget` makes the Editor start on that platform, so scripts compile with the right+`UNITY_*` defines before your method is called. Its values are lowercase names such as+`win64`, `osxuniversal`, `linux64`, `android`, `ios` and `webgl`.## A parameterised build method@@ -15,28 +23,25 @@ using UnityEngine;public static class CIBuild{- // Invoke with: -executeMethod CIBuild.Run -buildTarget Win64 -out Builds/Game.exe -version 1.2.3+ // Invoke with: -buildTarget win64 -executeMethod CIBuild.Run -out Builds/Game.exe -appVersion 1.2.3public static void Run(){string[] args = Environment.GetCommandLineArgs();- string targetArg = ArgValue(args, "-buildTarget", "Win64");- string outPath = ArgValue(args, "-out", "Builds/Game.exe");- string version = ArgValue(args, "-version", PlayerSettings.bundleVersion);- bool dev = args.Contains("-dev");-- BuildTarget target = targetArg switch+ if (!HasArg(args, "-buildTarget")){- "Win64" => BuildTarget.StandaloneWindows64,- "Mac" => BuildTarget.StandaloneOSX,- "Linux" => BuildTarget.StandaloneLinux64,- "Android" => BuildTarget.Android,- _ => throw new ArgumentException($"Unknown -buildTarget {targetArg}")- };+ // Without it the build silently uses whatever platform the project was last on.+ Debug.LogError("[CIBuild] pass -buildTarget <name> so the Editor starts on that platform");+ EditorApplication.Exit(2);+ return;+ }- // Switch the active target so the right platform defines/assets are used.- EditorUserBuildSettings.SwitchActiveBuildTarget(- BuildPipeline.GetBuildTargetGroup(target), target);+ string outPath = ArgValue(args, "-out", "Builds/Game.exe");+ string version = ArgValue(args, "-appVersion", PlayerSettings.bundleVersion);+ bool dev = HasArg(args, "-dev");++ // Already switched by -buildTarget at startup, with matching script defines.+ BuildTarget target = EditorUserBuildSettings.activeBuildTarget;PlayerSettings.bundleVersion = version; // stamp the version into the player@@ -53,7 +58,7 @@ public static class CIBuildif (s.result == BuildResult.Succeeded){- Debug.Log($"[CIBuild] OK {version} -> {outPath} ({s.totalSize} bytes)");+ Debug.Log($"[CIBuild] OK {target} {version} -> {outPath} ({s.totalSize} bytes)");EditorApplication.Exit(0); // explicit success exit code for CI}else@@ -66,9 +71,14 @@ public static class CIBuildprivate static string[] EnabledScenes() =>EditorBuildSettings.scenes.Where(sc => sc.enabled).Select(sc => sc.path).ToArray();+ private static int IndexOf(string[] args, string key) =>+ Array.FindIndex(args, a => string.Equals(a, key, StringComparison.OrdinalIgnoreCase));++ private static bool HasArg(string[] args, string key) => IndexOf(args, key) >= 0;+private static string ArgValue(string[] args, string key, string fallback){- int i = Array.IndexOf(args, key);+ int i = IndexOf(args, key);return (i >= 0 && i + 1 < args.Length) ? args[i + 1] : fallback;}}@@ -77,20 +87,41 @@ public static class CIBuild## Invoking from CI```bash-# Use -quit so the editor exits; the method itself also calls EditorApplication.Exit for clarity.+# No -quit needed: the method ends the process itself with EditorApplication.Exit.Unity -batchmode -nographics \-projectPath "$CI_PROJECT_DIR" \+ -buildTarget win64 \-executeMethod CIBuild.Run \- -buildTarget Win64 -out "Builds/Win/Game.exe" -version "1.2.$BUILD_NUMBER" \+ -out "Builds/Win/Game.exe" -appVersion "1.2.$BUILD_NUMBER" \-logFile - || exit 1```- Pipe `-logFile -` to stdout so the CI captures the Unity log.- `EditorApplication.Exit(code)` inside the method is the reliable way to set the exit code;- `-quit` alone returns 0 even after a logged error.+ an uncaught exception also exits with 1, but `-quit` after a `Debug.LogError` returns 0.+- One platform per Editor launch: run the command again with another `-buildTarget` for the+ next platform instead of switching inside the method.- Activate the Unity license in batch mode (`-username`/`-password`/`-serial` or a licensefile) as a separate step before building on a clean runner.+### Building a saved Build Profile with no script++If the team keeps its platform setup in Build Profile assets, Unity can build one directly:++```bash+Unity -batchmode -nographics -quit \+ -projectPath "$CI_PROJECT_DIR" \+ -activeBuildProfile "Assets/Settings/Build Profiles/WindowsRelease.asset" \+ -build "Builds/Win/Game.exe" \+ -logFile -+```++`-activeBuildProfile` takes a path relative to the project root and adds the profile's+scripting defines before compilation (it does not remove existing ones). Combined with+`-executeMethod` instead of `-build`, the defines are compiled in before your method runs; then+build with `BuildPipeline.BuildPlayer(new BuildPlayerWithProfileOptions { buildProfile = ..., locationPathName = ... })`+so the profile's own scene list and settings are used.+## Addressables content build (when used)```csharp@@ -101,15 +132,21 @@ public static void BuildContent(){AddressableAssetSettings.BuildPlayerContent(out var result);if (!string.IsNullOrEmpty(result.Error))- throw new Exception($"Addressables build failed: {result.Error}");+ throw new System.Exception($"Addressables build failed: {result.Error}");}```+Call it explicitly in CI even if the project's **Build Addressables on Player Build** setting+is on: when that setting is left at "Use global Settings", the answer comes from each+machine's Editor Preferences, so a clean runner may skip the content build.+## Gotchas-- `SwitchActiveBuildTarget` can take time and triggers a reimport; do it once per target, not- per build.-- Reading args via `Environment.GetCommandLineArgs()` includes Unity's own flags — match on- your custom keys only.+- Do not call `EditorUserBuildSettings.SwitchActiveBuildTarget` in batch mode; it is not+ available there. Use `-buildTarget` (or `-activeBuildProfile`) on the command line.+- Reading args via `Environment.GetCommandLineArgs()` includes Unity's own flags. Name custom+ keys so they cannot collide with a real Unity argument (`-buildTarget`, `-build`, `-quit`+ and `-version` are all taken; `-version` prints the Editor version and exits without+ building). `-out`, `-appVersion` and `-dev` are free.- A build server needs the platform module installed (e.g. IL2CPP toolchain, Android SDK/NDK)or the build fails late with a toolchain error.