Added basic lobby

This commit is contained in:
2026-05-20 21:03:54 +01:00
parent 48f8ae6c08
commit 6055fba959
15 changed files with 1019 additions and 6 deletions

View File

@@ -0,0 +1,36 @@
using PashaBibko.PenguinChase.Network;
using UnityEngine;
namespace PashaBibko.PenguinChase.Lobby
{
public class LobbyClientDisplayManager : MonoBehaviour
{
[Header("References")]
[SerializeField] private GameObject ClientDisplayPrefab;
[SerializeField] private GameObject ClientDisplayParent;
private int mCachedClientCount = -1; // Forces a refresh on initial load
private void Update()
{
// Checks if the client count has changed since last update
if (mCachedClientCount != GameNetworkClient.ConnectedClientCount)
{
// Clears all old client displays
foreach (Transform child in ClientDisplayParent.transform)
{
Destroy(child.gameObject);
}
// Creates new objects for each client
GameNetworkClient[] clients = GameNetworkClient.ConnectedClients;
foreach (GameNetworkClient client in clients)
{
GameObject go = Instantiate(ClientDisplayPrefab, ClientDisplayParent.transform);
LobbyClientDisplay display = go.GetComponent<LobbyClientDisplay>();
display.SetText(client);
}
}
}
}
}