创造你的世界
经济
使用产品样品
17 分
步骤 1 从 zepeto 产品示例开始 zepeto 产品示例 https //github com/naverz/world tutorial/tree/main/product zepeto 产品 api 参考 https //developer zepeto me/docs/product/ 以下是 zepeto 产品的示例实现。 要了解 zepeto 产品系统,我们建议您遵循指南以理解示例的实现。 示例包括货币系统、库存系统、物品获取、购买和 ui 资源的示例。 ❗️ 注意 在创建 zepeto 世界时,请随意使用示例中提供的 ui 资源和脚本。 但是,禁止使用发布示例中的资源,除非是 zepeto 世界。 如何应用 zepeto 产品示例 请在zepeto studio注册与样本中使用的名称相同的货币和产品。(如果货币id和产品id不同,则无法与样本链接。) 货币 true left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type 项目产品 true left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type 货币套餐产品 true left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type 项目包装产品 true left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type 2\) 将位于 assets/productsystem/prefab 的产品画布导入场景。 3\) 打开项目设置 > zepeto 服务,以检查世界是否正确连接。 4\) 运行 unity 菜单栏 > zepeto > 产品 > 设置。 如果货币和产品列表显示正常,链接将成功。 您可以验证 assets>product>resources 文件夹中的图标图像是否已设置。 您可以使用您选择的图像注册产品的图标照片。 ❗️ 注意 如果您无法正确查看产品,请检查以下内容。 请确保登录unity编辑器的帐户信息与world id创建者的信息相同。 确保在项目设置 > zepeto服务中的连接世界id信息是正确的。 请确认您已注册与示例中使用的相同id货币和产品。 5\) 请开启多服务器并按下播放按钮以运行示例。 步骤 2 理解zepeto产品示例 https //www youtube com/watch?v=jizxeaq nv8 ◦ 获得能量 当你点击一个按钮时,你会获得一个能量产品。 ◦ 使用能量 当你点击一个按钮时,你可以扣除一个能量物品。 ◦ 增加经验值 点击按钮获得10点经验值。如果你获得经验值并且等级提升,你将获得5个星币。 ◦ 获取随机物品 点击按钮随机将四种药水物品中的一种添加到库存中。 ◦ 立即购买 当你点击按钮时,你可以扣除一个能量物品并购买药水1。购买窗口不会出现,购买的物品会立即进入库存。 ◦ 通过ui购买 点击按钮,购买窗口将出现。你可以通过从购买窗口扣除10个星币来购买笔记1。 ◦ 购买物品包 点击按钮,购买窗口将出现。你可以通过从购买窗口扣除zepeto zem来购买药水包产品。 背包图标:点击按钮以显示库存窗口。您可以查看您拥有的物品列表,选择它们并使用。 购物车图标:当您点击按钮时,能量货币的购买窗口会出现。您可以通过从购买窗口中扣除zepeto zem来购买货币包产品。 zepeto 产品测试注意事项 当多服务器开启时,可以在沙盒服务器上进行 zepeto 产品测试。 在编辑器中所做的更改不会反映在 zepeto studio 中。 对预测试和发布世界所做的更改将反映在 zepeto studio 中。 当多服务器关闭时,沙盒测试环境将被初始化。(它将使用 zepeto studio 数据进行初始化。) 测试非消耗品 如果多服务器开启,一旦购买后将无法再次购买。 如果关闭多服务器,测试环境将被初始化,因此如果再次开启多服务器,您可以进行购买。 未注册世界封面图像,无法正确进行产品测试。请确保在 zepeto studio 中正确注册了世界封面图像。 步骤 3:购买产品后实施内容 样本在物品使用后不实施内容。 那部分必须按照世界生产者的意图直接实施。 请参考 uicommonbtn ts 中的脚本。 this multiplay room addmessagehandler\<inventorysync>("syncinventories", (message) => { this openinformation(`${message productid} 已在库存中 ${inventoryaction\[message inventoryaction]}。 // 物品使用示例 if(message inventoryaction == inventoryaction used){ if(message productid == "potion1"){ console log("使用药水!"); } } }); 关键是在使用产品时根据产品 id 实施内容代码。 如果您想在使用 potion2 时实施,请进行以下更改: this multiplay room addmessagehandler\<inventorysync>("syncinventories", (message) => { this openinformation(`${message productid} 已在库存中 ${inventoryaction\[message inventoryaction]}。 // 物品使用示例 if(message inventoryaction == inventoryaction used){ if(message productid == "potion2"){ console log("使用药水2!"); } } }); 要使用 zepeto 产品与服务器通信经济系统,需要分别实施服务器脚本和客户端脚本。 有关脚本实施,请参考 zepeto 产品示例和 zepeto 产品 api 中实施的示例脚本。

