文档

支持

Cloud Code

Unity Gaming Services(Unity 游戏服务)CLI

Create, deploy, and manage Cloud Code scripts using the Unity Gaming Services command-line interface.
阅读时间3 分钟最后更新于 1 个月前

您可以使用 Unity Gaming Services(Unity 游戏服务)CLI 来处理 Cloud Code 脚本。借助 CLI 可以从命令行创建、部署和管理 Cloud Code 脚本。

先决条件

要深入了解 CLI,请按照 Unity Gaming Services(Unity 游戏服务)CLI 入门指南中的步骤操作。 为了按照该指南操作,必须首先完成以下操作:
  1. 安装 UGS CLI
  2. 按如下方式配置 Project ID 和环境:
    ugs config set project-id <your-project-id>

    ugs config set environment-name <your-environment-name>
  3. 为服务帐户配置 Cloud Code环境管理所需的角色。请参阅接受身份验证

使用 CLI

请参阅 Cloud Code 命令行文档,了解所有命令和选项的完整参考。

部署脚本

运行
new-file
命令在本地创建包含示例代码的脚本:
ugs cloud-code scripts new-file <file-name>
您可以使用
Deploy
命令将本地脚本推送到远程环境并立即发布脚本。本地脚本必须经过部署之后才能用于游戏客户端。
ugs deploy <path-to-script-file> <path-to-script-file>
ugs deploy <path-to-directory>

获取脚本

要获取已部署的脚本的相关信息,请运行以下命令:
ugs cloud-code scripts get <script-name>
还可以通过运行以下命令列出当前部署到 Cloud Code 的所有脚本:
ugs cloud-code scripts list
您可以使用
Fetch
命令一次性从远程获取多个 Cloud Code 脚本。提供的路径是脚本将被提取到的目录:
ugs fetch <path>

环境同步

您可以将所有脚本从一个环境移动并部署到另一个环境。 运行以下命令以生成当前环境中所有脚本的存档:
ugs cloud-code scripts export <out-dir> <file-name>
然后,可以通过运行以下命令导入脚本并部署到另一个环境:
ugs cloud-code scripts import <in-dir> <file-name> --environment-name <environment-name>
脚本会自动发布。

删除脚本

要删除现有脚本,请运行以下命令:
ugs cloud-code scripts delete <script-name>

其他资源