question

brendan avatar image
brendan asked

Friends list bug

smartcarrion
started a topic on Sun, 07 December 2014 at 7:10 PM

Does anybody have the friends list working? I'm getting this weird type match bug when i try to retrieve the friends list. I've tried casting it a couple different ways, but maybe there is a Unity SDK bug? here is the error and some example code:

Assets/Scripts/PlayerStatus.cs(54,17): error CS0029: Cannot implicitly convert type System.Collections.Generic.List<PlayFab.ClientModels.FriendInfo>' toSystem.Collections.Generic.List<FriendInfo>'

    public void UpdateFriendsList(){
        if(PlayFabData.AuthKey != null){
            GetFriendsListRequest request = new GetFriendsListRequest();
            PlayFabClientAPI.GetFriendsList(request, OnGetFriendsList, OnPlayFabError);
        }
    }

    private void OnGetFriendsList(GetFriendsListResult result){
        friendList = result.Friends;  //this line throws the type conversion error
    }
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

Best Answer
smartcarrion said on Mon, 08 December 2014 at 4:15 PM

Looks like I can just declare it differently:

public List<PlayFab.ClientModels.FriendInfo> friendList;

instead of:

public List<FriendInfo> friendList;


4 Comments
Brendan Vanous said on Mon, 08 December 2014 at 2:51 PM

In this case, the top-level FriendInfo is defined separately from the PlayFab namespace's FriendInfo. It looks like the friendList is defined using the former (the top-level), which doesn't resolve to the PlayFab one. There are two possible fixes for this:

  1. Use the PlayFab namespace's FriendInfo for friendList.

  2. Iterate through the returned Friends and assign the data into friendList directly.

Brendan


smartcarrion said on Mon, 08 December 2014 at 4:11 PM

I found the bug! Photon Unity Networking also defines a 'FriendInfo' class. So one of them needs to change names, or i'll figure out how to cast one specifically. I know Playfab and Photon are planning to collaborate, so this is obviously something that will need to be fixed.

Thanks for your tip Brendan.


smartcarrion said on Mon, 08 December 2014 at 4:15 PM

Looks like I can just declare it differently:

public List<PlayFab.ClientModels.FriendInfo> friendList;

instead of:

public List<FriendInfo> friendList;


Brendan Vanous said on Mon, 08 December 2014 at 4:40 PM

Ah, thanks for pointing that out. We'll check with the Photon folks on getting their definitions into namespaces. But yes, fully qualifying would be the way to go.

Brendan

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.