Run custom commands in the Unity CLI
Use unity command to run custom commands and Pipeline package commands, list command group contents, and learn how the Unity CLI resolves commands.
Read time 3 minutesLast updated 4 days ago
Use to run commands defined with the attribute, including Pipeline package commands and your own custom commands.
unity command[CliCommand]Run a command
To run a command from the Unity CLI, pass its group, its name, and any arguments to :
unity commandunity command <group> <name> [args]
For example, the following command creates an Animator Controller with the command in the group:
create_controlleranimation.animatorunity command animation.animator create_controller
Type the group as a single token, with dots between subgroups. For example, type , not .
animation.animatoranimation animatorRun a command by its ID
You can also run a command by its ID:
unity command <group>.<name> [args]
In an ID, the last dot-separated segment is the command name and everything before it is the group. For example, runs the command in the group.
unity command build.runrunbuildRun a command without its group
Every command belongs to a group, but in some cases you can leave the group out when you run the command.
Run commands in the global group
Commands in the group can run with or without the group name. For example, if the group contains a command, the following commands are equivalent:
globalglobalstatusunity command global statusunity command status
When you run a command without a group, the Unity CLI looks up the name in the group first.
globalRun a command with a unique name
If no other group has a command with the same name, you can run the command without its group. For example, if exists only in the group, the following commands are equivalent:
create_controlleranimation.animatorunity command animation.animator create_controllerunity command create_controller
This shortcut only works for names that are unique across all groups. For example, exists in both the and groups, so you must include the group:
createanimation.clipanimation.timelineunity command animation.clip create
List commands in a group
To list the contents of a group, pass only the group:
unity command animation # Lists the contents of animation, such as subgroupsunity command animation.animator # Lists the contents of animation.animator, such as commands
Groups have no default command, so passing only a group always lists its contents instead of running a command.
How the Unity CLI resolves a command
The Unity CLI checks the first token after in the following order:
unity command- If the token is a group and a command name follows it, the Unity CLI runs that command.
- If the token is a group and nothing follows it, the Unity CLI lists the group's contents.
- If the token is a command ID, the Unity CLI runs that command.
- If the token is the name of a command in the group, the Unity CLI runs that command.
global - If the token isn't in the global group and is the name of a command that exists in only one group, the Unity CLI runs that command.
If the token doesn't match any of these cases, the Unity CLI returns an error. A single token that matches a group always lists that group, even if a command ID has the same spelling. For example, if the group has both a subgroup and a command:
buildbuild.targettargetunity command build.target # Lists the build.target subgroupunity command build target # Runs the target command in the build group