如何结合 playfab 和 photon 朋友的信息 [英] how to Combine between playfab and photon friend's info

查看:102
本文介绍了如何结合 playfab 和 photon 朋友的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用双关语 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:

Assuming you use the PlayFab integration with Photon as we recommend it, Photon UserID and PlayFab ID will be the same. So you can cache friends in a dictionary with keys set to their FriendID which is the Photon UserID / PlayFab ID and as values create a new class that combines info from PlayFab's FriendInfo and Photon's FriendInfo. Then periodically call PlayFab's GetFriends, inside its callback update the cached list of friends AND call Photon's FindFriends (when applicable / outside of rooms). In the callback of FindFriends update the cached friends' list and update the UI.

这篇关于如何结合 playfab 和 photon 朋友的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆