Singularity/Library/PackageCache/com.unity.collab-proxy@2.0.3/Editor/PlasticSCM/UI/Avatar/GetAvatar.cs

43 lines
1.0 KiB
C#
Raw Permalink Normal View History

2024-05-06 14:45:45 -04:00
using System;
using UnityEngine;
using PlasticGui;
namespace Unity.PlasticSCM.Editor.UI.Avatar
{
internal static class GetAvatar
{
internal static Texture2D ForEmail(
string email,
Action avatarLoadedAction)
{
if (string.IsNullOrEmpty(email))
return Images.GetEmptyGravatar();
if (AvatarImages.HasGravatar(email))
return AvatarImages.GetAvatar(email);
Texture2D defaultImage =
Images.GetEmptyGravatar();
AvatarImages.AddGravatar(email, defaultImage);
LoadAvatar.ForEmail(
email, avatarLoadedAction,
AfterDownloadSucceed);
return defaultImage;
}
static void AfterDownloadSucceed(
string email,
byte[] avatarBytes,
Action avatarLoadedAction)
{
AvatarImages.UpdateGravatar(email, avatarBytes);
avatarLoadedAction();
}
}
}