Closed nathansisler closed 3 years ago
social.LoadUsers should work with ids retrieved from leaderboards. Feel free to reopen if it doesn't works for you.
Had to run this coroutine for this to work. Might be helpful for anyone in the future.
Load scores with this :
PlayGamesPlatform.Instance.LoadScores(levelConfig, LeaderboardStart.TopScores, 1, LeaderboardCollection.Public, LeaderboardTimeSpan.AllTime, (LeaderboardScoreData data) => { curretHighScore = data.PlayerScore.value; string[] idString = new string[] { data.PlayerScore.userID }; Social.LoadUsers(idString, (users) => { highScoreUsername = users[0].userName; StartCoroutine(WaitPics(users[0])); }); });
then :
IEnumerator WaitPics(UnityEngine.SocialPlatforms.IUserProfile profile) {
yield return new WaitUntil(() =>
{
return profile.image != null;
});
Texture2D tempTex = profile.image;
highScoreUserImage2D.mainTexture = profile.image;
highScoreUserImage.sprite = Sprite.Create(tempTex, new Rect(0.0f, 0.0f, tempTex.width, tempTex.height), new Vector2(0.5f, 0.5f), 100.0f);
}
You guys have well documented how to retrieve a leaderboards scores and even usernames but now I'd like to get the top players avatar/image and it doesn't seem like you support it through the social.LoadUsers function. Are you doing that on purpose? is there another way to access the image?