2026-04-03 18:32:19 +08:00
|
|
|
using System;
|
2026-06-11 19:37:56 +08:00
|
|
|
using System.Collections;
|
2026-04-13 18:30:55 +08:00
|
|
|
using UnityEngine;
|
2026-06-11 19:37:56 +08:00
|
|
|
using UnityEngine.Networking;
|
|
|
|
|
using UnityEngine.Rendering;
|
2026-04-03 18:32:19 +08:00
|
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class UserBaseInfo
|
2026-03-09 09:25:01 +08:00
|
|
|
{
|
2026-04-13 18:30:55 +08:00
|
|
|
public Sprite avatarSprite;
|
2026-06-11 19:37:56 +08:00
|
|
|
public IEnumerator DownSprite(System.Action<Sprite> action)
|
|
|
|
|
{
|
|
|
|
|
string url = avatarUrl;
|
|
|
|
|
int downCount = 5;
|
|
|
|
|
if (avatarSprite != null)
|
|
|
|
|
{
|
|
|
|
|
action?.Invoke(avatarSprite);
|
|
|
|
|
yield break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Texture2D avatarTexture2D = new Texture2D(100, 100);
|
|
|
|
|
//if (avatarTexture2D == null)
|
|
|
|
|
for (int i = 0; i < downCount; i++)
|
|
|
|
|
{
|
|
|
|
|
using (UnityWebRequest www = UnityWebRequestTexture.GetTexture(url))
|
|
|
|
|
{
|
|
|
|
|
yield return www.SendWebRequest();
|
|
|
|
|
if (www.result == UnityWebRequest.Result.ConnectionError ||
|
|
|
|
|
www.result == UnityWebRequest.Result.ProtocolError)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("下载失败: " + www.error);
|
|
|
|
|
downCount--;
|
|
|
|
|
if (downCount == 0)
|
|
|
|
|
{
|
|
|
|
|
yield break;
|
|
|
|
|
|
|
|
|
|
//action.Invoke(Sprite.Create(new Texture2D(100, 100), new Rect(0, 0, 100, 100), new Vector2(0.5f, 0.5f)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
avatarTexture2D = DownloadHandlerTexture.GetContent(www);
|
|
|
|
|
avatarSprite = Sprite.Create(avatarTexture2D, new Rect(0, 0, avatarTexture2D.width, avatarTexture2D.height), new Vector2(0.5f, 0.5f));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
action?.Invoke(avatarSprite);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public void UpdateAvatar(System.Action<Sprite> action)
|
|
|
|
|
{
|
|
|
|
|
GameManager.Instance.StartCoroutine(DownSprite(action));
|
|
|
|
|
}
|
2026-03-09 09:25:01 +08:00
|
|
|
public string userName { get; set; }
|
|
|
|
|
public string password { get; set; }
|
|
|
|
|
public string number { get; set; }
|
|
|
|
|
public string avatarUrl { get; set; }
|
|
|
|
|
public string mobile { get; set; }
|
|
|
|
|
public string wxOpenId { get; set; }
|
|
|
|
|
public string channel { get; set; }
|
|
|
|
|
public bool isRedName { get; set; }
|
|
|
|
|
}
|