using UnityEngine; public class FunctionPreviewCell : MonoBehaviour { [SerializeField] ImageEx imgIcon; [SerializeField] TextEx txtName; [SerializeField] TextEx txtDesc; [SerializeField] ItemCell itemCell; [SerializeField] Transform transItemCellMask; [SerializeField] ImageEx imgRed; [SerializeField] TextEx txtOpenInfo; [SerializeField] Transform transMask; public void Display(int index, CellView cell) { int funcId = cell.info.Value.infoInt1; if (!FuncOpenLVConfig.HasKey(funcId)) return; FuncOpenLVConfig config = FuncOpenLVConfig.Get(funcId); // 0-未解锁 1-可领取 2-已领取 int state = FuncOpen.Instance.GetState(funcId); imgRed.SetActive(state == 1); txtOpenInfo.SetActive(state == 0); transMask.SetActive(state != 1); transItemCellMask.SetActive(state == 2); imgIcon.SetSprite(config.Icon); imgIcon.SetNativeSize(); txtName.text = config.Name; txtDesc.text = config.Desc; int[][] awardList = config.AwardList; itemCell.SetActive(!awardList.IsNullOrEmpty() && state != 0); if (!awardList.IsNullOrEmpty()) { itemCell.Init(new ItemCellModel(awardList[0][0], true, awardList[0][1])); itemCell.button.SetListener(() => { if (state == 1) { FuncOpen.Instance.SendGetAward(funcId); } else { ItemTipUtility.Show(awardList[0][0]); } }); } txtOpenInfo.text = FuncOpen.Instance.GetErrorStr(funcId); } }