问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/63651589/how-to-combine-between-playfab-and-photon-friends-info