54 lines
1.0 KiB
C#
54 lines
1.0 KiB
C#
using Sirenix.OdinInspector;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class PlayerItemUI : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private TextMeshProUGUI nameText;
|
|
|
|
[SerializeField]
|
|
private Image playerImage;
|
|
|
|
[SerializeField]
|
|
private GameObject emptyGroup;
|
|
|
|
[SerializeField]
|
|
private GameObject activeGroup;
|
|
|
|
[ReadOnly]
|
|
[SerializeField]
|
|
private PlayerInfo? playerInfo;
|
|
|
|
[SerializeField]
|
|
private Sprite defaultPlayerImage;
|
|
|
|
bool isEmpty => playerInfo == null;
|
|
|
|
private void Start()
|
|
{
|
|
UpdateUI();
|
|
}
|
|
|
|
public void Setup(PlayerInfo? playerInfo)
|
|
{
|
|
this.playerInfo = playerInfo;
|
|
UpdateUI();
|
|
}
|
|
|
|
private void UpdateUI()
|
|
{
|
|
emptyGroup.SetActive(isEmpty);
|
|
activeGroup.SetActive(!isEmpty);
|
|
|
|
if (!isEmpty)
|
|
{
|
|
nameText.text = playerInfo?.Name;
|
|
playerImage.sprite = playerInfo?.Image ?? defaultPlayerImage;
|
|
}
|
|
}
|
|
}
|