Image Manager

The google play AN_ImageManager class is used to load images from the network and handles local caching for you.

Load an Image by URL

Note that this does not support arbitrary URIs - the URI must be something that was retrieved from another call to Google Play services. The result is delivered to the given callback on the main thread.

Provided URL format should be similar to the example below:

content://com.google.android.gms.games.background/images/b4d1b8fd/2956

So for example, we have the RawImage  object

[SerializeField] RawImage m_userAvatar;

and we want to assign a current signed player avatar image to it. See the code sample below:

using SA.Android.GMS.Auth;
using SA.Android.GMS.Common.Images;

AN_PlayersClient client = AN_Games.GetPlayersClient();
client.GetCurrentPlayer((result) => {
    if(result.IsSucceeded) {
        AN_Player player = result.Data;
        AN_Logger.Log("player.Id: " + player.Id);

        if (!player.HasHiResImage) {
            var url = player.HiResImageUri;
            AN_ImageManager manager = new AN_ImageManager();
            manager.LoadImage(url, (imaheLoadResult) => {
                if (imaheLoadResult.IsSucceeded) {
                    m_userAvatar.texture = imaheLoadResult.Image;
                } else {
                    //Or you may want to assing some default texture here
                    m_userAvatar.texture = null;
                }
            });
        }
    } else {
        AN_Logger.Log("Failed to load Current Player " + result.Error.FullMessage);
    }
});