问题描述
我正在使用双关语 2 和 playfab.每次你添加一个新朋友时我都会这样做,它会将他添加到 playfab 列表中,这很好,因为我可以随时添加一个朋友,不像双关语 2 但我看不到朋友是否在线并获得朋友房间名称(光子选项).问题是我从 playfab 转换为光子.有没有办法做到这一点?这是我的 playfab 代码
private void DisplayPlayfabFriends(ListfriendCache){foreach(FriendCache 中的 PlayFab.ClientModels.FriendInfo f){bool isfound = false;如果(我的朋友!= null){foreach (PlayFab.ClientModels.FriendInfo g in myfriends){if (f.FriendPlayFabId == g.FriendPlayFabId){isfound = true;}}}if(isfound == false){UIFriend 列表 = Instantiate(uiPrefab, container);如果(上市!= null){列表.初始化(f);listing.friendNameText.text = f.TitleDisplayName;}}}我的朋友 = 朋友缓存;}
这是光子代码
公共无效初始化(Photon.Realtime.FriendInfofriendInfo){信息 = 朋友信息;roomName = ${infophoton.UserId}";friendNameText.text = $"{info.UserId}";如果(信息光子.IsOnline){onlineImage.color = onlineColor;}别的{onlineImage.color = offlineColor;}}如何将两者结合起来?
我在Photon官方论坛回复此处.引用我的回复:
假设您按照我们的建议使用 PlayFab 与 Photon 的集成它,Photon UserID 和 PlayFab ID 将是相同的.所以你可以缓存字典中的朋友,键设置为他们的 FriendID,这是Photon UserID/PlayFab ID 和作为值创建一个新类结合来自 PlayFab 的 FriendInfo 和 Photon 的 FriendInfo 的信息.然后定期调用 PlayFab 的 GetFriends,在其回调中更新缓存的好友列表并调用 Photon 的 FindFriends(适用时)/房间外).在 FindFriends 的回调中更新缓存的好友列表并更新用户界面.
I am using pun 2 and playfab. I did that every time you add a new friend it adds him to a playfab list, this is good because I can add a friend in any time, not like pun 2 but I can't see if friends are online and get the friends room name(photon option). the problem is that I convert from playfab to photon. is there a way to do it?here is my playfab code
private void DisplayPlayfabFriends(List<PlayFab.ClientModels.FriendInfo> friendCache)
{
foreach (PlayFab.ClientModels.FriendInfo f in friendCache)
{
bool isfound = false;
if(myfriends != null)
{
foreach (PlayFab.ClientModels.FriendInfo g in myfriends)
{
if (f.FriendPlayFabId == g.FriendPlayFabId)
{
isfound = true;
}
}
}
if(isfound == false)
{
UIFriend listing = Instantiate(uiPrefab, container);
if(listing != null)
{
listing.Initialize(f);
listing.friendNameText.text = f.TitleDisplayName;
}
}
}
myfriends = friendCache;
}
here is the photon code
public void Initialize(Photon.Realtime.FriendInfo friendInfo)
{
info = friendInfo;
roomName = $"{infophoton.UserId}";
friendNameText.text = $"{info.UserId}";
if (infophoton.IsOnline)
{
onlineImage.color = onlineColor;
}
else
{
onlineImage.color = offlineColor;
}
}
how to Combine between them both?
I replied on the official Photon forum here.Quoting my reply:
这篇关于如何结合 playfab 和 photon 朋友的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!