question

Alamin mohammed avatar image
Alamin mohammed asked

How do you remove friend from friend list display?

I am using Unity. I have been able to successfully add a friend and display it on a friend list using their playfab display name. However when I remove the friend, the friend remains on the friend list.

I have to close the game and restart it for the friend list to update. Is there a way to have it delete the current friend from the list immediately (would I have to destroy the cloned object).?

I have parts of my code below which are attached to a button.

void DisplayFriends(List<FriendInfo> friendsCache)
    {
       
        foreach (FriendInfo f in friendsCache)


        {
            bool isFound = false;
            if (myFriends != null)


            
                 foreach (FriendInfo g in myFriends)
                {
                    
                    if (f.FriendPlayFabId == g.FriendPlayFabId)
                    {
                        isFound = true;
                        Debug.Log("TEST friend removal HERE");
                    }


                   
                }




            if (isFound == false)
            {
             GameObject listing = Instantiate(listingPrefab, friendScrollView);
             PlayerListing templisting = listing.GetComponent<PlayerListing>();
             templisting.PlayerNameText.text = f.TitleDisplayName;
                
            }
        }
        myFriends = friendsCache;
    }




 void RemoveFriend(FriendInfo friendInfo)
    {
        PlayFabClientAPI.RemoveFriend(new RemoveFriendRequest
        {
            FriendPlayFabId = friendInfo.FriendPlayFabId
        }, result => {
            _friends.Remove(friendInfo);
            
            
            


        },
        DisplayPlayFabFriendsError);
        DisplayFriends(_friends);
        Debug.Log("removing friend part 3");
        
    }

unity3dFriends
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

·
Citrus Yan avatar image
Citrus Yan answered

Basically, you need to destroy/disable the current friend’s entry (the cloned object) from the friend list when PlayFabClientAPI.RemoveFriend returns a success callback. And, actually, this is a Unity UI-related question, please find more professional help from the Unity Forum: Unity Forum

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.

Error rendering WebPanel (widgets/consolidation-widget.ftl): org.hibernate.hql.internal.ast.QuerySyntaxException: AvailableConsolidation is not mapped [from AvailableConsolidation up where up.node = :node]