Add party to lobby menu
This commit is contained in:
50
Assets/Scripts/UI/PlayerItemUI.cs
Normal file
50
Assets/Scripts/UI/PlayerItemUI.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user