1
This commit is contained in:
@@ -208,17 +208,38 @@ public class UIHome_BY_EmailPanel : SubUIBase
|
||||
foreach (var prop in email.rewardItems)
|
||||
{
|
||||
if (prop == null) continue;
|
||||
string url = ResolveItemImageUrl(prop);
|
||||
list.Add(new BackPackPropItemData
|
||||
{
|
||||
giftType = 3,
|
||||
url = APIManager.baseURL + prop.imageUrl,
|
||||
url = string.IsNullOrEmpty(url) ? "" : APIManager.baseURL + url,
|
||||
count = prop.count,
|
||||
propEnum = (PropEnum)ResolveItemPropType(prop),
|
||||
});
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析邮件道具图片相对地址:优先用后端下发的 imageUrl,
|
||||
/// 未下发时按约定格式补全 /uploads/{编号}.png。
|
||||
/// </summary>
|
||||
private static string ResolveItemImageUrl(RewardItem prop)
|
||||
{
|
||||
if (prop == null) return "";
|
||||
if (!string.IsNullOrEmpty(prop.imageUrl)) return prop.imageUrl;
|
||||
return string.IsNullOrEmpty(prop.number) ? "" : $"/uploads/{prop.number}.png";
|
||||
}
|
||||
|
||||
/// <summary>通过 number 在 propConfig 中查找道具类型(用于背景框)</summary>
|
||||
private static int ResolveItemPropType(RewardItem prop)
|
||||
{
|
||||
if (prop == null || string.IsNullOrEmpty(prop.number)) return prop?.type ?? 0;
|
||||
var match = GameManager.Instance?.gameConfig?.propConfig?.Find(p => p.number == prop.number);
|
||||
return match?.type ?? prop.type;
|
||||
}
|
||||
|
||||
protected override void OnShow(object args = null)
|
||||
{
|
||||
base.OnShow(args);
|
||||
@@ -354,10 +375,15 @@ public class UIHome_BY_EmailPanel : SubUIBase
|
||||
foreach (var prop in item.rewardItems)
|
||||
{
|
||||
GameObject obj = Instantiate(propPrefab, propPrefabParent);
|
||||
WebTool.DownImage(APIManager.baseURL+ prop.imageUrl, (texture) =>
|
||||
string itemUrl = ResolveItemImageUrl(prop);
|
||||
if (!string.IsNullOrEmpty(itemUrl))
|
||||
{
|
||||
obj.transform.GetChild(0).GetComponent<Image>().sprite = Sprite.Create(texture,new Rect(0f,0f,texture.width,texture.height),Vector2.one*0.5f);
|
||||
});
|
||||
WebTool.DownImage(APIManager.baseURL + itemUrl, (texture) =>
|
||||
{
|
||||
if (obj == null) return;
|
||||
obj.transform.GetChild(0).GetComponent<Image>().sprite = Sprite.Create(texture,new Rect(0f,0f,texture.width,texture.height),Vector2.one*0.5f);
|
||||
});
|
||||
}
|
||||
obj.transform.GetChild(0).GetChild(0).GetComponent<TextMeshProUGUI>().text = prop.count.ToString();
|
||||
if (item.isReward)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user