Beispiel #1
0
    /// <summary>
    /// Downloads the trophy icon.
    /// </summary>
    /// <param name='trophy'>
    /// The trophy.
    /// </param>
    /// <param name='OnComplete'>
    /// The callback.
    /// </param>
    public void DownloadTrophyIcon(GJTrophy trophy, Action <Texture2D> OnComplete)
    {
        GJAPIHelper.DownloadImage(
            trophy.ImageURL,
            icon =>
        {
            if (icon == null)
            {
                icon = (Texture2D)Resources.Load("Images/TrophyIcon", typeof(Texture2D)) ?? new Texture2D(75, 75);
            }

            if (OnComplete != null)
            {
                OnComplete(icon);
            }
        });
    }
    /// <summary>
    /// Downloads the user avatar.
    /// </summary>
    /// <param name='user'>
    /// The user.
    /// </param>
    /// <param name='OnComplete'>
    /// The callback.
    /// </param>
    public void DownloadUserAvatar(GJUser user, Action <Texture2D> OnComplete)
    {
        GJAPIHelper.DownloadImage(
            user.AvatarURL,
            avatar =>
        {
            if (avatar == null)
            {
                avatar = (Texture2D)Resources.Load("Images/UserAvatar", typeof(Texture2D)) ?? new Texture2D(60, 60);
            }

            if (OnComplete != null)
            {
                OnComplete(avatar);
            }
        });
    }