你的下一项功能
玩家资料
显示玩家的头像、头像框和徽章。
Unity

可见的结果
重新加载个人资料后,所选头像、头像框或徽章会显示出来。
此步骤尚无视频。指南和MCP请求已可使用。
使用玩家资料
实现此功能
你可以预览指南。运行需要有效的项目密钥。 准备项目
已安装 SDK、导入项目配置,且玩家已登录。
此 SDK 示例使用 develop。请检查已安装的 SDK 是否具备所需 API。
C#
1using UnityEngine;
2using PM.horizOn.Cloud.Core;
3using PM.horizOn.Cloud.Manager;
4
5// 将此脚本挂到第一个场景中的某个 GameObject 上。
6public class PlayerProfileDemo : MonoBehaviour
7{
8 async void Start()
9 {
10 // 准备:初始化、连接并登录玩家。
11 HorizonApp.Initialize();
12 await new HorizonServer().Connect();
13 await UserManager.Instance.SignUpAnonymous("PlayerName");
14
15 // horizOn:读取资料,然后修改头像、头像框和徽章。
16 // Profile, unlocks and the cosmetics catalog of the signed in player
17 var profile = await PlayerProfileManager.Instance.GetProfile();
18 if (profile == null) { Debug.Log(PlayerProfileManager.Instance.LastErrorCode); return; }
19
20 // Save avatar, frame and up to three badges (ids from your catalog in the dashboard)
21 var updated = await PlayerProfileManager.Instance.SetProfile(
22 "avatar.zombie_07", profile.profile.frameId, new[] { "badge.supporter" });
23 }
24}
测试你的新功能。
重新加载个人资料后,所选头像、头像框或徽章会显示出来。
在仪表盘中选择与游戏配置相同的项目。


