question

Tanmay Kulkarni avatar image
Tanmay Kulkarni asked

Display Friends error

When i add an id as friend, it adds successfully but when i try to get friends list, the unity console gives an error - MenuController.DisplayFriends (System.Collections.Generic.List`1[T] friendsCache)

What to do?

entitiesFriends
10 |1200

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

Citrus Yan avatar image
Citrus Yan answered

Would you please share the code that's causing this error? A complete reproduce step would be helpful.

27 comments
10 |1200

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

Tanmay Kulkarni avatar image Tanmay Kulkarni commented ·

first script:

void DisplayFriends(List<PlayFab.ClientModels.FriendInfo> friendsCache)


    {
        loadingPanel.SetActive(false);
        foreach(PlayFab.ClientModels.FriendInfo f in friendsCache)
        {
            fl.Instantiate(f.TitleDisplayName, f.Profile.Statistics[6].Value, myFriendListing, myFriendsScrollView, f.Profile.Statistics[1].Value);
        }
        
    }
    List<FriendInfo> _friends = null;



0 Likes 0 ·
Tanmay Kulkarni avatar image Tanmay Kulkarni commented ·

the refrenced script (fl)

public void Instantiate(string name, int medals, GameObject listing, Transform scrollView, int avatar)
    {
        GameObject mf = Instantiate(listing, scrollView);
        Text Name = mf.transform.GetChild(0).GetComponent<Text>();
        Name.text = name;
        Image Avatar = mf.transform.GetChild(1).GetComponent<Image>();
        Avatar.sprite = av.AllAvatars[avatar];
        Text Medals = mf.transform.GetChild(3).GetComponent<Text>();
        Medals.text = medals.ToString();




    }

0 Likes 0 ·
Tanmay Kulkarni avatar image Tanmay Kulkarni commented ·

The error is on first script

MenuController.DisplayFriends (System.Collections.Generic.List`1[T] friendsCache)
0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Tanmay Kulkarni commented ·

What's the full stack trace and error detail?

0 Likes 0 ·
Tanmay Kulkarni avatar image Tanmay Kulkarni Citrus Yan commented ·

The error when I call the function DisplayFreinds() is

0 Likes 0 ·
2020-03-29-1.png (26.8 KiB)
Show more comments
Tanmay Kulkarni avatar image Tanmay Kulkarni Tanmay Kulkarni commented ·

It stopped giving that error for a while but after sometime it gave same error even if i have not called the statistics

-1 Like -1 ·
Citrus Yan avatar image Citrus Yan Tanmay Kulkarni commented ·

That shouldn't be a error from PlayFab , you may need to debug your code to find the root cause.

0 Likes 0 ·
Show more comments
Tanmay Kulkarni avatar image Tanmay Kulkarni commented ·

@Citrus Yan

I am using this code for getting

 void GetFriends()
    {
        loadingPanel.SetActive(true);
        PlayFabClientAPI.GetFriendsList(new GetFriendsListRequest
        {
            IncludeSteamFriends = false,
            IncludeFacebookFriends = false,
            XboxToken = null,
            ProfileConstraints = new PlayerProfileViewConstraints()
            {
                ShowStatistics = true, ShowDisplayName = true
            }
        }, result =>
        {
            _friends = result.Friends;
            DisplayFriends(_friends); // triggers your UI
        }, DisplayPlayFabError) ; 
    }
0 Likes 0 ·
Tanmay Kulkarni avatar image Tanmay Kulkarni commented ·
@Citrus Yan

And this for displaying

   void DisplayFriends(List<PlayFab.ClientModels.FriendInfo> friendsCache)


    {
        loadingPanel.SetActive(false);
        foreach(FriendInfo f in friendsCache)
        {
            GameObject mf = Instantiate(myFriendListing, myFriendsScrollView);
            string tdn = f.TitleDisplayName;
            fl.NameText.text = tdn;
           
            
                            


        }
        
    }
0 Likes 0 ·
Show more comments
Citrus Yan avatar image
Citrus Yan answered

@Tanmay KulkarniI've created a test account (Displayname : CitrusYanTest) in your title and added "ArnavPoar" as Friend. When debugging the code your provided, I get the following:

The "f.TitleDisplayname" field is correct, hence this may not be a issue from PlayFab side, you should probably debug your code to find what's really going on.


info.png (24.3 KiB)
10 |1200

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

Citrus Yan avatar image
Citrus Yan answered
@Tanmay Kulkarni

This is the code I used for testing:

using PlayFab;
using UnityEngine;
using PlayFab.ClientModels;
public class test : MonoBehaviour
{
    
    // Start is called before the first frame update
    void Start()
    {
        PlayFabSettings.TitleId = "96638";
        PlayFabClientAPI.LoginWithCustomID(new LoginWithCustomIDRequest { CreateAccount = false, CustomId = "CitrusYanTest", TitleId = "96638" }, OnLoginSuccessLocal, null);


    }
    private void OnLoginSuccessLocal(LoginResult result)
    {
        Debug.Log("login success");
        GetFriends();




    }


    private void GetFriends()
    {
        PlayFabClientAPI.GetFriendsList(new GetFriendsListRequest
        {
            IncludeSteamFriends = false,
            IncludeFacebookFriends = false,
            XboxToken = null,
            ProfileConstraints = new PlayerProfileViewConstraints()
            {
                ShowStatistics = true,
                ShowDisplayName = true
            }
        }, result =>
        {
            foreach (FriendInfo f in result.Friends)
            {
                
                string tdn = f.TitleDisplayName;


            }
            Debug.Log("friend display name:" + result.Friends[0].TitleDisplayName); 


        }, OnErrorShared);
    }


    private static void OnErrorShared(PlayFabError error)
    {
        Debug.Log(error.GenerateErrorReport());
    }


}


10 |1200

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

Tanmay Kulkarni avatar image
Tanmay Kulkarni answered
@Citrus Yan

This showed the same error

1 comment
10 |1200

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

Citrus Yan avatar image Citrus Yan commented ·

Would you please add a breakpoint into your code and check the full result from the GetFriendsList request? Moreover, a fiddler trace would also be helpful.

0 Likes 0 ·
Tanmay Kulkarni avatar image
Tanmay Kulkarni answered
@Citrus Yan

I would really thank you.

You have solved the problem. I used your code once and it worked, but I am unable to find that what I was doing wrong?

I would really rate PlayFab 5 stars for best community support.

Thank You So Much!

1 comment
10 |1200

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

Citrus Yan avatar image Citrus Yan commented ·

Glad it helped, you may need to debug your code step by step to find the root cause

0 Likes 0 ·

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.