Unity 游戏中的活动
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本主题介绍了如何在 Unity 游戏中使用 Play 游戏服务活动。
准备工作
设置您的 Unity 项目和适用于 Unity 的 Google Play 游戏插件。如需了解详情,请参阅入门指南。
创建活动
您可以在 Google Play 管理中心内创建活动。如需了解详情,请参阅 Play 游戏服务活动指南。创建活动后,请按照入门指南中的说明将活动的 Android 资源添加到插件中。
记录活动
若要为活动设置递增机制,请调用以下方法:
using GooglePlayGames;
...
// Increments the event with Id "YOUR_EVENT_ID" by 1
PlayGamesPlatform.Instance.Events.IncrementEvent("YOUR_EVENT_ID", 1);
您只需调用一次。该方法会在后台处理批量作业和执行。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Events in Unity games\n\nThis topics describes how to use Play Games Services events in Unity\ngames.\n\nBefore you get started\n----------------------\n\nSet up your Unity project and the Google Play Games plugin for Unity. For\ndetails, see the [Get started guide](/games/pgs/unity/unity-start).\n\nCreate events\n-------------\n\nYou create events in Google Play Console. For details, see the\n[events guide](/games/pgs/events#create-event) for Play Games Services. After\nyou create your events, add their Android resources to the plugin as described\nin the [get started guide](/games/pgs/unity/unity-start).\n\nRecord events\n-------------\n\nTo increment an event, call the following method: \n\n using GooglePlayGames;\n ...\n // Increments the event with Id \"YOUR_EVENT_ID\" by 1\n PlayGamesPlatform.Instance.Events.IncrementEvent(\"YOUR_EVENT_ID\", 1);\n\nYou only need to make this call once. It handles batching and execution in the\nbackground."]]