You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using Fusion;
|
|
|
|
public class SessionInfoUIListItem : MonoBehaviour
|
|
{
|
|
public TextMeshProUGUI sessionName;
|
|
public Button joinButton;
|
|
|
|
private SessionInfo sessionInfo;
|
|
public event Action<SessionInfo> OnJoinSession;
|
|
|
|
public void SetSessionInfo(SessionInfo sessionInfo)
|
|
{
|
|
if (sessionName == null)
|
|
{
|
|
Debug.LogError($"[SessionInfoUIListItem] sessionName is null on '{name}'. Please assign a TextMeshProUGUI.");
|
|
return;
|
|
}
|
|
if (joinButton == null)
|
|
{
|
|
Debug.LogError($"[SessionInfoUIListItem] joinButton is null on '{name}'. Please assign a Button.");
|
|
return;
|
|
}
|
|
|
|
this.sessionInfo = sessionInfo;
|
|
sessionName.text = sessionInfo.Name;
|
|
joinButton.interactable = sessionInfo.PlayerCount < sessionInfo.MaxPlayers;
|
|
|
|
joinButton.onClick.RemoveAllListeners();
|
|
joinButton.onClick.AddListener(OnClick);
|
|
}
|
|
|
|
private void OnClick()
|
|
{
|
|
OnJoinSession?.Invoke(sessionInfo);
|
|
}
|
|
}
|