yyl
2026-03-04 bc1cb6da854cb2e9144f10ed55330a537ecdca16
Main/System/TimingGift/TimingGiftCell.cs
@@ -1,14 +1,21 @@
using UnityEngine;
using Cysharp.Threading.Tasks;
public class TimingGiftCell : MonoBehaviour
{
    private void Awake()
    {
        //如果有需要按钮点击逻辑,在外层创建,此处不处理点击逻辑
        LoadPrefab();
        InitAsync().Forget();
    }
    private async UniTask InitAsync()
    {
        //如果有需要按鈕点击逻辑,在外层创建,此处不处理点击逻辑
        await LoadPrefab();
        if (this == null) return;
        button.SetListener(() =>
        {
            UIManager.Instance.OpenWindow<TimingGiftWin>(type);
            UIManager.Instance.OpenWindowAsync<TimingGiftWin>(type).Forget();
        });
    }
@@ -110,7 +117,7 @@
        }
    }
    protected void LoadPrefab()
    protected async UniTask LoadPrefab()
    {
        if (prefab != null)
            return;
@@ -121,16 +128,23 @@
            prefab = tmp.gameObject;
            return;
        }
        prefab = UIUtility.CreateWidget("TimingGiftCell", "TimingGiftCell");
        prefab = await UIUtility.CreateWidget("TimingGiftCell", "TimingGiftCell");
        if (this == null)
        {
            if (null != prefab) DestroyImmediate(prefab);
            return;
        }
        prefab.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one);
        prefab.transform.SetAsFirstSibling();
    }
    public void InitUI()
    public async UniTask InitUI()
    {
        LoadPrefab();   //存在被卸载的可能,重新加载
        await LoadPrefab();   //存在被卸载的可能,重新加载
        if (this == null) return;
        Display();
    }