Search Unity

Social.LoadUsers

Discussion in 'iOS and tvOS' started by Peter Hou, Dec 2, 2013.

  1. Peter Hou

    Peter Hou

    Joined:
    Oct 12, 2010
    Posts:
    66
    Hi,

    Does anyone have an example of how to use Social.LoadUsers? The documentation is a little lacking and I can't seem to wrap my head around it :)

    http://docs.unity3d.com/Documentation/ScriptReference/Social.LoadUsers.html

    My goal is to extract usernames and scores from a leaderboard, but I've only been able to find examples of how to get usernames from the local user's friends like this:
    Code (csharp):
    1.  
    2. for (int i=0; i < Social.localUser.friends.Length; i++)
    3. {
    4.     if (score.userID == Social.localUser.friends[i].id)
    5.     {
    6.         curUserName = Social.localUser.friends[i].userName;
    7.     }                      
    8. }              
    9.  
    So, I need a way to get usernames for those userIDs who are not friends of the local user. Any help?
     
  2. Peter Hou

    Peter Hou

    Joined:
    Oct 12, 2010
    Posts:
    66
    No one knows how to use Social.LoadUsers? That's unfortunate :sad:
     
  3. shloob

    shloob

    Joined:
    Jun 1, 2013
    Posts:
    10
    Hey there, in order to use Social.LoadUsers you would do something like this ( I am sure you solved this by now, but in case others are still curious :)

    void LoadLeaderboardUsers(string[] userIDs)
    {
    Debug.Log("There was " + userIDs.Length + " user ids");
    if(authenticated)
    {
    Social.LoadUsers(userIDs, OnLeaderboardUsersLoaded);
    }
    }

    void OnLeaderboardUsersLoaded(IUserProfile[] profiles)
    {
    Debug.Log("There was " + profiles.Length + " profiles loaded");
    foreach(IUserProfile profile in profiles)
    {
    Debug.Log("PROFILE NAME = " + profile.userName);
    }
    }
     
  4. domdev

    domdev

    Joined:
    Feb 2, 2015
    Posts:
    375
    will crashed at Social.LoadUsers(userIDs, OnLeaderboardUsersLoaded);