From unicli
Automates Unity Editor via UniCli: edit Assets/Packages files, compile C# code, run EditMode/PlayMode tests, modify GameObjects, scenes, prefabs, assets, build/project settings.
npx claudepluginhub yucchiy/unicli --plugin unicliThis skill uses the workspace's default tool permissions.
UniCli lets you interact with Unity Editor directly from the terminal.
Automates Unity Editor from terminal via ucp CLI over WebSocket/JSON-RPC: scenes, GameObjects, assets, prefabs, builds, tests, packages, debugging. Use for headless project inspection, modification, and workflows.
Inspects and controls Unity Editor state via unity-cli: ping editor, read console output, update project settings, run menu items, manage windows/selection/packages/profiler.
CLI for reading scenes/prefabs/assets, small updates, deletes, and utilities in Unity projects without live editor bridge. Emits structured JSON; boot with setup/status.
Share bugs, ideas, or general feedback.
UniCli lets you interact with Unity Editor directly from the terminal.
The CLI (unicli) communicates with the Unity Editor over named pipes, so the Editor must be open with the com.yucchiy.unicli-server package installed.
Assets/ or Packages/: Run unicli exec AssetDatabase.Import --path "<path>" --json to generate .meta files. Never create .meta files manually — always let Unity generate them via this command. Unity requires .meta files for every asset — skipping this causes missing references, broken imports, and compilation errors. This applies to all file types: .cs, .asmdef, .asset, .prefab, directories, etc.unicli exec Compile --json to verify compilation.--json when parsing output programmatically.unicli exec BuildPlayer.Compile --target <platform> --json to catch platform-specific errors (missing #if guards, unsupported APIs, etc.).--resultFilter failures (or --resultFilter none for summary-only) to keep output minimal. Only use --resultFilter all when you specifically need to inspect individual passed test details. This prevents large test suites from flooding context. Stack traces are omitted by default (--stackTraceLines 0); use --stackTraceLines 3 when you need to diagnose a failure location.--logType "Warning,Error" to filter out informational noise and focus on actionable issues. Stack traces are omitted by default; use --stackTraceLines 3 when debugging errors.unicli commands --json to list all available commands and unicli exec <command> --help to see parameters for any command. Do not rely on memorized command lists — the project may have custom commands.By default, unicli looks for a Unity project in the current working directory.
If the Unity project is in a subdirectory, set the UNICLI_PROJECT environment variable:
export UNICLI_PROJECT=path/to/unity/project
unicli exec Compile --json
Or prefix each command:
UNICLI_PROJECT=path/to/unity/project unicli exec Compile --json
Before running commands, verify that the CLI is installed and the Editor is reachable:
unicli check
If unicli check reports that the server package is not installed, run unicli install to install it:
unicli install
If the server package version does not match the CLI version, run unicli install --update to update it:
unicli install --update
If the package is installed but the connection fails, make sure Unity Editor is open with the target project loaded. Retry a few times — the Editor may need a moment to start the server.
Run commands with unicli exec <command>. Pass parameters as --key value flags:
unicli exec GameObject.Find --name "Main Camera" --json
Boolean flags can be passed without a value:
unicli exec GameObject.Find --includeInactive --json
Array parameters can be passed by repeating the same flag:
unicli exec BuildPlayer.Build --locationPathName "Builds/Test.app" --options Development --options ConnectWithProfiler --json
--json — Output in JSON format (recommended for structured processing)--timeout <ms> — Set command timeout in milliseconds--no-focus — Don't bring Unity Editor to front--help — Show command parameters and usageCompile and run tests:
unicli exec Compile --json
unicli exec TestRunner.RunEditMode --json
unicli exec TestRunner.RunPlayMode --json
Inspect and modify settings:
unicli exec PlayerSettings.Inspect --json
unicli eval 'PlayerSettings.companyName = "MyCompany";' --json
Dynamic C# code execution (Eval):
unicli eval compiles and executes arbitrary C# code in the Unity Editor context. Use shell heredocs for multi-line code:
unicli eval 'return Application.unityVersion;' --json
unicli eval "$(cat <<'EOF'
var go = GameObject.Find("Main Camera");
return go.transform.position;
EOF
)" --json
Options:
--declarations '<code>' — Additional type declarations (classes, structs, enums) included outside the Execute methodcancellationToken variable for cooperative cancellation with async/awaitWhen built-in commands don't cover what you need, choose the right approach:
unicli eval for ad-hoc operations, quick inspections, prototyping, and tasks that don't need to be reused. No files to create or compile — just pass the code directly.CommandHandler when the operation will be called repeatedly or is part of the project's workflow. This provides type-safe parameters, structured responses, and discoverability via unicli commands.Connect to a running player:
Connection.* commands manage the Unity Editor's PlayerConnection — used to connect to Development Builds running on devices or the local machine. This connection is required for remote debug commands and profiler data collection.
unicli exec Connection.List --json # List available targets
unicli exec Connection.Connect '{"id":-1}' --json # Connect by player ID
unicli exec Connection.Connect '{"ip":"192.168.1.100"}' --json # Connect by IP
unicli exec Connection.Connect '{"deviceId":"SERIAL"}' --json # Connect by device serial
unicli exec Connection.Status --json # Check connection status
Invoke remote debug commands on connected player:
Remote.* commands invoke debug commands on a connected Development Build. Requires: UNICLI_REMOTE scripting define symbol + Development Build with Autoconnect Profiler enabled.
unicli exec Remote.List --json
unicli exec Remote.Invoke '{"command":"Debug.Stats"}' --json
unicli exec Remote.Invoke '{"command":"Debug.GetPlayerPref","data":"{\"key\":\"HighScore\",\"type\":\"int\"}"}' --json
Built-in debug commands: Debug.SystemInfo, Debug.Stats, Debug.GetLogs, Debug.GetHierarchy, Debug.FindGameObjects, Debug.GetScenes, Debug.GetPlayerPref
The server auto-discovers all ICommandHandler implementations via TypeCache, so no manual registration is required.
Place custom handlers under Assets/Editor/UniCli/ with a dedicated asmdef:
# 1. Create asmdef and add reference to UniCli.Server.Editor
unicli exec AssemblyDefinition.Create --path "Assets/Editor/UniCli/MyProject.UniCli.Editor.asmdef" --name "MyProject.UniCli.Editor" --editorOnly --json
unicli exec AssemblyDefinition.AddReference --path "Assets/Editor/UniCli/MyProject.UniCli.Editor.asmdef" --reference "UniCli.Server.Editor" --json
# 2. Create handler script, then import and compile
unicli exec AssetDatabase.Import --path "Assets/Editor/UniCli" --json
unicli exec Compile --json
# 3. Verify registration and execute
unicli commands --json
unicli exec MyCategory.MyAction --targetName "test" --json
using System.Threading;
using System.Threading.Tasks;
using UniCli.Protocol;
using UniCli.Server.Editor.Handlers;
namespace MyProject.UniCli.Editor.Handlers
{
[System.Serializable]
public class MyRequest
{
public string targetName = "";
}
[System.Serializable]
public class MyResponse
{
public string result;
}
public sealed class MyCustomHandler : CommandHandler<MyRequest, MyResponse>
{
public override string CommandName => "MyCategory.MyAction";
public override string Description => "Description shown in unicli commands";
protected override ValueTask<MyResponse> ExecuteAsync(MyRequest request, CancellationToken cancellationToken)
{
return new ValueTask<MyResponse>(new MyResponse
{
result = $"Processed {request.targetName}"
});
}
}
}
Key rules:
[Serializable] with public fields (not properties) — required by JsonUtilityUnit as TRequest when no input is needed, or as TResponse when no output is neededCommandFailedException with response data on failureTaskCompletionSource + await with WithCancellation(cancellationToken) to wait for Unity callbacksServiceRegistry for dependency injectionunicli commands --json to discover all available commands, including project-specific custom commands.unicli exec <command> --help to see parameters, types, and default values for any command.unicli exec Compile --timeout 60000.