Files
5.24BuYu/Assets/MyGame/aa/UI/Home/Sub/SelectGameLeave/SelectGameLeave_DefaultUIItem.cs
T
2026-07-06 02:08:18 +08:00

51 lines
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class SelectGameLeave_DefaultUIItem : MonoBehaviour
{
public TextMeshProUGUI tMP_Name;
public Image sprite_Avatar;
public Image sprite_AvatarFrame;
public TextMeshProUGUI tMP_GoldCount;
public TextMeshProUGUI tMP_DiamodCount;
public Button btn_StartQuickly;
public Button btn_FanHui;
public Button btn_SheZhi;
private void OnEnable()
{
GameManager.Instance.OnAvatarChanged += OnAvatarChanged;
GameManager.Instance.OnAvatarFrameChanged += OnAvatarFrameChanged;
}
private void OnDisable()
{
if (GameManager.Instance != null)
{
GameManager.Instance.OnAvatarChanged -= OnAvatarChanged;
GameManager.Instance.OnAvatarFrameChanged -= OnAvatarFrameChanged;
}
}
private void OnAvatarChanged(Sprite sprite)
{
if (sprite != null) sprite_Avatar.sprite = sprite;
}
private void OnAvatarFrameChanged(Sprite sprite)
{
if (sprite_AvatarFrame != null && sprite != null)
sprite_AvatarFrame.sprite = sprite;
}
public void UpdateData(string name, string gold, string diamod)
{
tMP_Name.text = name;
tMP_GoldCount.text = gold;
tMP_DiamodCount.text = diamod;
}
}