Example #1
0
    public void GetUserHighScoreProfilePicture(UserHighScore userHighScore, int?width = null, int?height = null, string type = null)
    {
        string path = Path.Combine(Application.persistentDataPath, userHighScore.UserId + "_ProfilePicture.png");

        if (File.Exists(path) && DateTime.Now - File.GetLastWriteTime(path) < TimeSpan.FromDays(this.DaysToKeepProfilePicture))
        {
            userHighScore.ProfilePicture = TextureIo.ReadTextureFromFile(
                path, width ?? userHighScore.ProfilePicture.width, height ?? userHighScore.ProfilePicture.height);
        }
        else
        {
            string url = this.GetPictureURL(userHighScore.UserId, width, height, type);
            FB.API(
                url,
                HttpMethod.GET,
                result =>
            {
                if (result.Error != null)
                {
                    FbDebug.Error(result.Error);

                    return;
                }

                userHighScore.ProfilePicture = result.Texture;
                TextureIo.SaveTextureToFile(path, userHighScore.ProfilePicture);
            });
        }
    }
Example #2
0
    private void OnGetProfilePictureCompleted(FBResult result)
    {
        if (result.Error != null)
        {
            FbDebug.Error(result.Error);

            return;
        }

        this.ProfilePicture = result.Texture;
        TextureIo.SaveTextureToFile(this.profilePicturePath, this.ProfilePicture);
        this.NotifyProfilePictureRetreived(this.ProfilePicture);
    }
Example #3
0
 public void GetProfilePicture(int?width = null, int?height = null, string type = null)
 {
     if (File.Exists(this.profilePicturePath) &&
         DateTime.Now - File.GetLastWriteTime(this.profilePicturePath) < TimeSpan.FromDays(this.DaysToKeepProfilePicture))
     {
         this.ProfilePicture = TextureIo.ReadTextureFromFile(
             this.profilePicturePath, width ?? this.ProfilePicture.width, height ?? this.ProfilePicture.height);
         this.NotifyProfilePictureRetreived(this.ProfilePicture);
     }
     else
     {
         string url = this.GetPictureURL("me", width, height, type);
         FB.API(url, HttpMethod.GET, this.OnGetProfilePictureCompleted);
     }
 }