Unity Gaming Services(Unity 游戏服务)CLI
Create, deploy, and manage Cloud Code scripts using the Unity Gaming Services command-line interface.
阅读时间3 分钟最后更新于 8 个月前
您可以使用 Unity Gaming Services(Unity 游戏服务)CLI 来处理 Cloud Code 脚本。借助 CLI 可以从命令行创建、部署和管理 Cloud Code 脚本。
先决条件
要深入了解 CLI,请按照 Unity Gaming Services(Unity 游戏服务)CLI 入门指南中的步骤操作。
为了按照该指南操作,必须首先完成以下操作:
-
按如下方式配置 Project ID 和环境:
ugs config set project-id <your-project-id>
ugs config set environment-name <your-environment-name>
使用 CLI
请参阅 Cloud Code 命令行文档,了解所有命令和选项的完整参考。
部署脚本
运行 命令在本地创建包含示例代码的脚本:
new-fileugs cloud-code scripts new-file <file-name>
您可以使用 命令将本地脚本推送到远程环境并立即发布脚本。本地脚本必须经过部署之后才能用于游戏客户端。
Deployugs 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
您可以使用 命令一次性从远程获取多个 Cloud Code 脚本。提供的路径是脚本将被提取到的目录:
Fetchugs 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>