-
Notifications
You must be signed in to change notification settings - Fork 1
Image Manager
Koretsky Konstantin edited this page May 11, 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;
var client = AN_Games.GetPlayersClient();
client.GetCurrentPlayer(result => {
if(result.IsSucceeded) {
var player = result.Data;
Debug.Log($"player.Id: {player.PlayerId}");
Debug.Log($"player.DisplayName: {player.DisplayName}");
Debug.Log($"player.HiResImageUri: {player.HiResImageUri}");
Debug.Log($"player.IconImageUri: {player.IconImageUri}");
Debug.Log($"player.HasIconImage: {player.HasIconImage}");
Debug.Log($"player.HasHiResImage: {player.HasHiResImage}");
if (!player.HasHiResImage) {
var url = player.HiResImageUri;
var manager = new AN_ImageManager();
manager.LoadImage(url, imaheLoadResult => {
m_userAvatar.texture = imaheLoadResult.IsSucceeded ? imaheLoadResult.Image : null;
});
}
} else {
Debug.LogError($"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