Unity Gaming Services CLI

You can use the Unity Gaming Services CLI to interact with Cloud Code scripts. The CLI allows you to create, deploy, and manage Cloud Code scripts from the command line.


For a deep dive into the CLI, follow the steps in the Unity Gaming Services CLI Get Started guide.

To follow this guide, you must first complete the following actions:

  1. Install the UGS CLI.

  2. Configure your Project ID and Environment as such:
    ugs config set project-id <your-project-id>
    ugs config set environment-name <your-environment-name>

  3. Configure a Service Account with the required roles for Cloud Code and environments management. Refer to Get Authenticated.

Using the CLI

Refer to the Cloud Code Command Line documentation for a full reference of all commands and options.

Note: The ugs cloud-code scripts command is also available as ugs cc s.

Deploy scripts

Run the new-file command to create a script with sample code locally:

ugs cloud-code scripts new-file <file-name>

You can use the Deploy command to promote your local scripts to the remote environment and publish them at once. The local scripts must be deployed to become available to the game client.

ugs deploy <path-to-script-file> <path-to-script-file>
ugs deploy <path-to-directory>

Retrieve scripts

To retrieve information about the deployed scripts, run the following command:

ugs cloud-code scripts get <script-name>

You can also list all scripts currently deployed to Cloud Code by running the following command:

ugs cloud-code scripts list

You can use the Fetch command to retrieve multiple Cloud Code scripts from remote at once. The provided path is a directory where the scripts will be fetched to:

ugs fetch <path>

Note: If there are parameters declared from service, and there's no parameter in service script code, the Fetch command will update the local script code and append parameters to it. Refer to Parameter parsing.

Environment synchronization

You can move all your scripts from one environment and deploy them to another environment.

Run the following command to produce an archive of all the scripts in your current environment:

ugs cloud-code scripts export <out-dir> <file-name>

You can then import the scripts and deploy them to another environment by running the following command:

ugs cloud-code scripts import <in-dir> <file-name> --environment-name <environment-name>

The scripts are published automatically.

Note: Import does not overwrite your environment by default. If you would like to delete existing scripts before importing, use the --reconcile flag.

Delete script

To delete an existing script, run the following command:

ugs cloud-code scripts delete <script-name>

Additional resources