57 lines
1.4 KiB
C#
57 lines
1.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
using UnityEngine.UI;
|
|
|
|
namespace TcgEngine
|
|
{
|
|
public class ChangeCoverLine : MonoBehaviour
|
|
{
|
|
public Image cover;
|
|
public Image currentCover;
|
|
public string coverName;
|
|
|
|
private Button cover_settings_btn;
|
|
public UnityAction<ChangeCoverLine> OnChangeCover;
|
|
|
|
/// <summary>
|
|
/// 初始化封面显示
|
|
/// </summary>
|
|
public void SetCover(Sprite coverSprite, string name)
|
|
{
|
|
if (cover != null)
|
|
cover.sprite = coverSprite;
|
|
coverName = name;
|
|
cover_settings_btn = cover.GetComponent<Button>();
|
|
cover_settings_btn.onClick.AddListener(OnClickCover);
|
|
}
|
|
|
|
public void RefreshCurrentCover(string coverName)
|
|
{
|
|
if (currentCover != null)
|
|
{
|
|
Debug.Log(coverName);
|
|
if (this.coverName == coverName)
|
|
{
|
|
currentCover.color = Color.yellow;
|
|
}
|
|
else
|
|
{
|
|
currentCover.color = Color.white;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击选择封面
|
|
/// </summary>
|
|
private void OnClickCover()
|
|
{
|
|
Debug.Log(coverName);
|
|
OnChangeCover?.Invoke(this);
|
|
}
|
|
}
|
|
}
|
|
|