Skip to main content
Industry & SpecializedGame Production39 lines

Unity Editor Batchmode and Command Line Builds

Run isolated Unity builds and tests from the CLI with the pinned editor, explicit target, separate logs and verified outputs.

Quick Summary18 lines
Read the project's editor version, package manifest and supported targets. Use the matching editor executable and target modules. Run builds in a clean checkout or a worker copy. A project already open in another editor instance should get a separate checkout or a deliberate handoff before batchmode. Verify licensing availability without printing or embedding credentials.

## Key Points

- [Unity Editor command line arguments](https://docs.unity3d.com/6000.0/Documentation/Manual/EditorCommandLineArguments.html)
- [Unity Test Framework command line](https://docs.unity3d.com/Packages/com.unity.test-framework@1.4/manual/reference-command-line.html)

## Quick Example

```text
Unity -batchmode -projectPath PROJECT -runTests -testPlatform EditMode -testResults RESULTS.xml -logFile TEST.log
```

```text
Unity -batchmode -quit -projectPath PROJECT -buildTarget StandaloneWindows64 -executeMethod BuildScripts.BuildWindows64 -logFile BUILD.log
```
skilldb get game-production-skills/unity-batchmodeFull skill: 39 lines
Paste into your CLAUDE.md or agent config

Unity Editor Batchmode and Command Line Builds

Read the project's editor version, package manifest and supported targets. Use the matching editor executable and target modules. Run builds in a clean checkout or a worker copy. A project already open in another editor instance should get a separate checkout or a deliberate handoff before batchmode. Verify licensing availability without printing or embedding credentials.

Run tests and builds separately

Use distinct output paths and retain independent logs. For the Unity Test Framework, verify the flags against the installed package. A representative Edit Mode invocation is:

Unity -batchmode -projectPath PROJECT -runTests -testPlatform EditMode -testResults RESULTS.xml -logFile TEST.log

Avoid adding -quit to the test invocation when the Test Framework documentation warns it can exit before asynchronous tests finish. Parse the XML and require a nonzero expected test count. For Play Mode, use the documented test platform and the graphics configuration the tests actually require. A headless result is insufficient for a graphics-dependent assertion.

For builds, use the project's reviewed build method, or use the supported native build flags for its editor version. An example with a static method is:

Unity -batchmode -quit -projectPath PROJECT -buildTarget StandaloneWindows64 -executeMethod BuildScripts.BuildWindows64 -logFile BUILD.log

Use an existing method with that signature or implement a method that checks the BuildReport and returns failure explicitly. Record the exact selected profile, build arguments, target architecture, build output path and editor version. Verify scripts are safe to run before invoking them from a checkout.

Verify output evidence

Check process status and log together. Require a fresh result XML with expected counts for tests. For builds, validate fresh expected file paths, package size, manifest or metadata, and one supported startup smoke test. Keep the logs on failure. A successful import with no build artifact is a failed build. Distinguish a compile error, unavailable license, missing module, failed test and output verification failure before retrying.

Test the pipeline with a known compile failure or failing synthetic test and confirm it cannot leave a prior artifact marked current. Retry in a fresh output directory after the cause is corrected. Keep the verified package and test evidence paired with the source revision.

Sources

Install this skill directly: skilldb add game-production-skills

Get CLI access →