文档

​
​

Development

User Acquisition

Monetization

工业

Triggers

Open Unity Dashboard

Triggers

LiveOps
​
​
Get started
  • Overview
  • Get started
  • Set up triggers example workflow
  • Authentication
Set up events
  • Understand and manage events
  • Schedule events
Define triggers
  • Define triggers
    • Trigger structure
    • Filters
    • Define triggers with the CLI
    • Define triggers with the REST API
    • Define triggers with the Unity Dashboard
Configure actions
  • Use Cloud Code
  • Use webhooks
Manage and monitor
  • Use the dead letter queue (DLQ)
  • Limits
  • Failure handling
Examples and reference
  • Use case samples
  1. Triggers
  2. Define triggers

Unity Gaming Services(Unity 游戏服务)CLI

Manage trigger configurations from the command line using the Unity Gaming Services command-line interface.
阅读时间3 分钟
最后更新于 5 个月前

您可以使用 Unity Gaming Services(Unity 游戏服务)CLI 来处理触发器。通过 CLI 可以从命令行管理触发器配置。
注意
注意:此 CLI 不支持带有过滤器的触发器。要创建带有过滤器的触发器,请使用 Triggers Admin API 或 Unity Dashboard。

先决条件

如需了解 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. 为服务帐户配置 Triggers 和环境管理所需的角色。请参阅接受身份验证。

使用 CLI

如需了解所有命令和选项的完整参考,请参阅 Triggers 命令行文档。
注意
注意:
ugs triggers
命令也可按照
ugs tr
的形式使用。

部署触发器

运行
new-file
命令在本地创建触发器配置:
ugs triggers new-file <file-name>
配置文件内容可能如下所示:
{ "$schema": "https://ugs-config-schemas.unity3d.com/v1/triggers.schema.json", "Configs": [ { "Name": "example-trigger", "EventType": "com.unity.services.scheduler.{{EVENT_NAME}}.v{{EVENT_VERSION}}", "ActionUrn": "urn:ugs:cloud-code:MyScript", "ActionType": "cloud-code" } ]}
还可以修改配置文件来包含多个触发器:
{ "$schema": "https://ugs-config-schemas.unity3d.com/v1/triggers.schema.json", "Configs": [ { "Name": "example-trigger", "EventType": "com.unity.services.scheduler.{{EVENT_NAME}}.v{{EVENT_VERSION}}", "ActionUrn": "urn:ugs:cloud-code:MyScript", "ActionType": "cloud-code" }, { "Name": "example-trigger-2", "EventType": "com.unity.services.scheduler.{{EVENT_NAME}}.v{{EVENT_VERSION}}", "ActionUrn": "urn:ugs:cloud-code:MyScript", "ActionType": "cloud-code" } ]}
您可以使用
Deploy
命令将本地触发器配置文件推送到远程环境。
您需要部署配置文件后才能激活触发器:
ugs deploy <path-to-triggers-file> <path-to-triggers-file>
ugs deploy <path-to-directory>
如果您将触发器与现有 Cloud Code 脚本或模块相关联,则发出指定
eventType
的事件会使触发器触发,并会执行关联的 Cloud Code 脚本或模块。

获取触发器

您可以使用
Fetch
命令一次性从远程获取多个触发器。
提供的路径是保存触发器的目录:
ugs fetch <path>

删除触发器

要删除触发器,您可以运行带
--reconcile
标志的
deploy
命令。
警告
警告: 协调 (reconcile) 是一项破坏性操作。它会删除所提供路径中不存在的所有触发器。您可以先检查带
--dry-run
标志的命令的输出,然后再运行不带该标志的命令。
ugs deploy --services triggers <path-to-triggers-file> --reconcile

Copyright © 2026 Unity Technologies
法律信息隐私政策CookiesDocumentation Terms of Use请勿出售或分享我的个人信息您的隐私选择(Cookie 设置)

“Unity”、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属公司在美国和其他地方的商标或注册商标(此处查看更多信息)。其他名称或品牌是其各自所有者的商标。

为方便起见,一些页面是机器翻译的,可能包含不准确的内容。如有信息不一致的情况,以英文版本为准。

  • 在本页上
    • 先决条件

    • 使用 CLI

      • 部署触发器

      • 获取触发器

      • 删除触发器


报告此页面的问题