Files
tcg-client/Assets/TcgEngine/Scripts/Menu/ChangeCoverPanel.cs
2025-10-09 14:20:54 +08:00

68 lines
1.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace TcgEngine.UI
{
public class ChangeCoverPanel : UIPanel
{
public Text coverNameText;
public Transform content;
public GameObject coverPrefab;
private static ChangeCoverPanel instance;
protected override void Awake()
{
base.Awake();
instance = this;
for (int i = 0; i < content.childCount; i++)
Destroy(content.GetChild(i).gameObject);
}
protected override void Start()
{
base.Start();
GenerateCardCovers();
}
/// <summary>
/// 生成并排布所有卡片封面
/// </summary>
private void GenerateCardCovers()
{
Debug.Log("数据有"+CardCoverData.GetAll().Count);
foreach (CardCoverData cover in CardCoverData.GetAll())
{
GameObject cardCover = Instantiate(coverPrefab, content);
var line = cardCover.GetComponent<ChangeCoverLine>();
line.SetCover(cover.GetCardCover(), cover.name);
}
}
private void RefreshPanel()
{
}
public void OpenPanel(DeckLine line)
{
Show();
RefreshPanel();
coverNameText.text = line.title.text;
}
public override void Show(bool instant = false)
{
base.Show(instant);
}
public static ChangeCoverPanel Get()
{
return instance;
}
}
}