你的下一项功能
物品
为所选项目管理独立装备、属性、目录规则与玩家背包。
Unity

可见的结果
保存后目录包含starter_sword。完成核对后的示例购买后,当前背包包含其唯一instanceId。
此步骤尚无视频。指南和MCP请求已可使用。
物品
准备同一个项目
实现此功能
你可以预览指南。运行需要有效的项目密钥。 准备项目
已安装 SDK、导入项目配置,且玩家已登录。
此 SDK 示例使用 develop。请检查已安装的 SDK 是否具备所需 API。
先通过快速入门连接目标玩家,再通过明确的按钮或场景操作调用ReadCatalogPage(), ReadInventory()。仅打开文件不会发送请求。
C#
1using UnityEngine;
2using PM.horizOn.Cloud.Manager;
3
4public sealed class ItemsDemo : MonoBehaviour
5{
6 // Initialize/connect and restore the existing player in the Quickstart first.
7 public async void ReadInventory()
8 {
9 var user = UserManager.Instance.CurrentUser;
10 if (user == null || !user.IsValid()) return;
11 var result = await ItemsManager.Instance.GetInventory(user.UserId);
12 if (!result.IsSuccess) { Debug.LogWarning(result.ErrorCode); return; }
13 foreach (var item in result.Data.instances)
14 Debug.Log($"{item.instanceId}: {item.itemKey}");
15 // Keep result.Data.revision for a separately reviewed mutation.
16 }
17
18 // Wire a separate explicit action; no automatic catalog traversal or poll.
19 public async void ReadCatalogPage()
20 {
21 var user = UserManager.Instance.CurrentUser;
22 if (user == null || !user.IsValid()) return;
23 var result = await ItemsManager.Instance.GetCatalog(user.UserId, limit: 1);
24 if (!result.IsSuccess) { Debug.LogWarning(result.ErrorCode); return; }
25 Debug.Log($"Catalog revision: {result.Data.revision}");
26 // Explicit Next keeps result.Data.revision and nextAfterKey unchanged.
27 }
28}
29// SDK ItemsExample/ItemsSampleStore persist original instanceId/body/revision before writes.
30// Keep the original Player Values operationId for purchase recovery.
31// The initial success may include item references; retained replay may return empty applied/items.
32// Read the current inventory separately. Never reconstruct earlier item references.
33// A failed refresh never authorizes a replacement purchase or a local item grant.
使用已保存的物品
导入官方示例及辅助文件。核对报价后,用现有玩家按下方顺序执行。等待每一步完成,只确认购买一次。响应不确定时保留原始请求。
ItemsExample: projectId → ReadOneCatalogPage() → ReviewOffers() → SavePurchaseAfterReview("starter-sword") → RefreshInventory()
测试你的新功能。
保存后目录包含starter_sword。完成核对后的示例购买后,当前背包包含其唯一instanceId。
在仪表盘中选择与游戏配置相同的项目。


