你的下一项功能
交易市场
让两名玩家交易同一件原始库存物品。
Unity

可见的结果
买家获得原物品,卖家获得约定价格扣除已配置手续费后的金额。
此步骤尚无视频。指南和MCP请求已可使用。
交易市场
准备同一个项目
实现此功能
你可以预览指南。运行需要有效的项目密钥。 准备项目
已安装 SDK、导入项目配置,且玩家已登录。
此 SDK 示例使用 develop。请检查已安装的 SDK 是否具备所需 API。
先通过快速入门连接目标玩家,再通过明确的按钮或场景操作调用ReadListing(listingId)。仅打开文件不会发送请求。
C#
1using System.Threading.Tasks;
2using UnityEngine;
3using PM.horizOn.Cloud.Examples.Features;
4using PM.horizOn.Cloud.Objects.Network.Responses;
5
6public class MarketplaceDemo : MonoBehaviour
7{
8 // Import the SDK Examples sample. Bind its screen to the signed-in player
9 // and set the stable projectId in the Inspector. Never use an Account Key.
10 public MarketplaceExample screen;
11
12 public Task<MarketplaceResult<MarketplaceListingView>> ReadListing(string listingId)
13 => MarketplaceQuickstart.ReadOneListing(screen, listingId);
14
15 // Wire only to the player's Buy confirmation after displaying ReadListing.
16 public Task<bool> ConfirmPurchase(string listingId)
17 => MarketplaceQuickstart.BuyReviewedListing(screen, listingId);
18
19 // false/timeout does not prove nonexecution. Use screen.RetryPending() or
20 // screen.RecoverOriginalOperation(); never replace the unresolved original.
21 // The sample refreshes Inventory, Values and Marketplace before acknowledgement.
22 // Its native file journal rejects WebGL writes; use a durable browser persister.
23}
使用两名玩家测试
使用同一项目中已登录的两名玩家。配置货币、手续费和价格规则,挂售一件未装备的物品,并明确确认购买。
使用现有的登录会话。购买结果未确认时,保留并重试同一原始请求,然后刷新库存和余额。
取消后,原始物品仍受到保护,直到所有者领取。仅当前所有者已被删除时才能恢复分配。
挂单和重复操作保护只在项目中存储一次。玩家仅保留引用和有限的状态数据。
测试你的新功能。
买家获得原物品,卖家获得约定价格扣除已配置手续费后的金额。
在仪表盘中选择与游戏配置相同的项目。
接口
- GET
/marketplace/limits - GET
/marketplace/rules - GET
/marketplace - GET
/marketplace/listings - GET
/marketplace/listings/{listingId} - POST
/marketplace/listings - POST
/marketplace/listings/{listingId}/buy - POST
/marketplace/listings/{listingId}/cancel - GET
/marketplace/operations/{operationId} - POST
/marketplace/listings/{listingId}/retry-return


