Commit f7feec31 authored by nanahira's avatar nanahira

use better face API

parent cc571d84
Pipeline #15263 failed with stages
in 9 minutes and 6 seconds
......@@ -119,33 +119,17 @@ public class MyCardHelper {
public static void DownloadFace(string name) {
try {
WWW www = new WWW("https://sapi.moecube.com:444/accounts/users/"+WWW.EscapeURL(name, Encoding.UTF8)+".avatar");
while (!www.isDone) {
if (Application.internetReachability == NetworkReachability.NotReachable || !string.IsNullOrEmpty(www.error))
{
return;
}
string face = "textures/face/" + name + ".png";
HttpDldFile df = new HttpDldFile();
df.Download("https://sapi.moecube.com:444/avatar/avatar/" + name + "/100/koishipro2.png", face);
if (File.Exists(face))
{
Texture2D Face = UIHelper.getTexture2D(face);
UIHelper.faces.Remove(nameFace);
UIHelper.faces.Add(nameFace, Face);
}
string result = www.text;
if(result == "{\"message\":\"Not Found\"}")
return;
DownloadFaceFromUrl(name, result);
} catch (Exception e) {
return;
}
}
private static void DownloadFaceFromUrl(string nameFace, string url)
{
string face = "textures/face/" + nameFace + ".png";
HttpDldFile df = new HttpDldFile();
df.Download(url, face);
if (File.Exists(face))
{
Texture2D Face = UIHelper.getTexture2D(face);
UIHelper.faces.Remove(nameFace);
UIHelper.faces.Add(nameFace, Face);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment