-
Notifications
You must be signed in to change notification settings - Fork 1
Image Manager
levching edited this page Apr 10, 2020
·
5 revisions
The google play AN_ImageManager class is used to load images from the network and handles local caching for you.
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);
}
});Reliable and high-quality Unity Development service. Let's Talk!
Website | AssetStore | LinkedIn | Youtube | Scripting Reference
- Build Info
- Dark Mode
- Package Info
- Runtime Permissions
- Run External App
- Immersive Mode
- PackageManager
- Popups & Preloaders
- Rate Us Dialog
- Activity
- Intent
- Settings Page
- Media Player
- Date Picker Dialog
- Time Picker Dialog
- Locale
- Wheel Picker Dialog
- Developer Console Setup
- Connecting to The Service
- Purchase Flow
- Transactions Validation
- Subscriptions
- Licensing
- Getting Started
- Games Sing-in
- Server-side API Access
- Leaderboards
- Achievements
- Saved Games
- Image Manager
- Settings Intent