How to get image , name from google play leaderboard

How to get all players image , name from google play leader board.

i have seen score getting from google play leaderboard link , but how to get images and names

I try to use data.Scores[] but it cannot use for getting image and name

Hi,

For anyone looking how to get user image from google play game, I managed to do it! Here is the code

public Image playerImage; // Player's image where image must be displayed
    public Text nameText; // Player's name text
    
   public IEnumerator TimedLoadUserImageAndName()
    {
        // If not authenticated then just break the loop, we don't need errors
        if(!PlayGamesPlatform.Instance.IsAuthenticated())
        {
            Debug.Log("Player not authenticated! from Load Image");
            yield break;
        }

        Texture2D userImage;
        string playerName;

        // While the image and names are not loaded just keep trying to load it
        while(PlayGamesPlatform.Instance.localUser.image == null || PlayGamesPlatform.Instance.localUser.userName == null)
        {
            Debug.Log("Image and name Not Loaded");
            yield return null;
        }

        // finally we got the name as well as image!
        Debug.Log("Woah! We got a image and player name :)");

        userImage = PlayGamesPlatform.Instance.localUser.image;
        playerName = PlayGamesPlatform.Instance.localUser.userName;

        // Convert the texture we got to a sprite and assign it to the image, as well as assign player name
        playerImage.sprite = Sprite.Create(userImage, new Rect(0, 0, userImage.width, userImage.height), Vector2.zero);
        nameText.text = playerName;
        yield break;
    }

Just call StartCoroutine(TimedLoadUserImageAndName()); whenever you want the image.
Also don’t forget to assign the Image component in the inspector.

Note : I couldn’t figure out a way to get these details of other users, but this will get player data. If anyone could find a solution to get name and image of other users just post it here even I need to know it!

Hope this helps :slight_smile: