Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private async UniTask GetAvatarIconAsync()
- {
- if (Application.isEditor)
- return;
- if (GP_Player.IsLoggedIn() == false)
- return;
- string avatarUrl = GP_Player.GetAvatarUrl();
- if (string.IsNullOrEmpty(avatarUrl))
- return;
- UnityWebRequest downloadAvatarRequest;
- try
- {
- downloadAvatarRequest = await UnityWebRequestTexture.GetTexture(avatarUrl).SendWebRequest();
- }
- catch (UnityWebRequestException exception)
- {
- _logService.LogError($"An error occurred while downloading user's avatar: {exception.Text}");
- return;
- }
- if (downloadAvatarRequest.result != UnityWebRequest.Result.Success)
- return;
- DownloadHandlerTexture textureDownloadHandler = (DownloadHandlerTexture)downloadAvatarRequest.downloadHandler;
- Texture2D texture = textureDownloadHandler.texture;
- if (texture == null)
- return;
- Avatar = texture;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement