存
This commit is contained in:
@@ -16,9 +16,10 @@ public class GuaGuaLeGPU : SubUIBase, IPointerDownHandler, IDragHandler
|
||||
{
|
||||
[Header("UI 引用(必填)")]
|
||||
public RawImage scratchImage; // 最上层:涂层遮罩(挂此脚本)
|
||||
public TextMeshProUGUI tmp_AwardName; // 中间层:奖品文字
|
||||
public GuaGuaLeItem giftPrefab; // 奖品预制体(用于显示奖品图片)
|
||||
public Transform giftPrefabParent;
|
||||
public Sprite sprite_Gold;
|
||||
public Sprite sprite_Diamond;
|
||||
|
||||
[Header("材质(模板)")]
|
||||
public Material maskMat; // 使用 ScratchMask.shader(涂层遮罩)
|
||||
@@ -110,22 +111,29 @@ public class GuaGuaLeGPU : SubUIBase, IPointerDownHandler, IDragHandler
|
||||
{
|
||||
APIRequestList.ScratchCardDraw(result =>
|
||||
{
|
||||
if (result == null) return;
|
||||
if (result == null || giftPrefab == null) return;
|
||||
|
||||
currentAward = result.prizeName ?? "谢谢参与";
|
||||
if (tmp_AwardName != null)
|
||||
tmp_AwardName.text = currentAward;
|
||||
|
||||
// 清除旧的奖励物品
|
||||
for (int i = giftPrefabParent.childCount - 1; i >= 0; i--)
|
||||
Destroy(giftPrefabParent.GetChild(i).gameObject);
|
||||
|
||||
// 显示奖品图片(baseProduct.imageUrl)
|
||||
string imgUrl = result.baseProduct?.imageUrl;
|
||||
if (!string.IsNullOrEmpty(imgUrl) && giftPrefab != null)
|
||||
var item = Instantiate(giftPrefab, giftPrefabParent);
|
||||
|
||||
switch (result.prizeType)
|
||||
{
|
||||
var item = Instantiate(giftPrefab, giftPrefabParent);
|
||||
item.Init(imgUrl, result.count);
|
||||
case 1: // 金币 → 本地 sprite
|
||||
item.Init(sprite_Gold, result.count);
|
||||
break;
|
||||
case 2: // 钻石 → 本地 sprite
|
||||
item.Init(sprite_Diamond, result.count);
|
||||
break;
|
||||
default: // 道具 → 网络下载图片
|
||||
string imgUrl = result.baseProduct?.imageUrl;
|
||||
if (!string.IsNullOrEmpty(imgUrl))
|
||||
item.Init(imgUrl, result.count);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -154,8 +162,7 @@ public class GuaGuaLeGPU : SubUIBase, IPointerDownHandler, IDragHandler
|
||||
|
||||
ClearRT(maskRT, Color.black);
|
||||
|
||||
if (tmp_AwardName != null)
|
||||
tmp_AwardName.text = currentAward;
|
||||
|
||||
onRevealed?.Invoke();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user