mirror of
https://github.com/ConjureETS/ProjectClubCore.git
synced 2026-03-24 17:40:59 +00:00
Added PlayerList
This commit is contained in:
parent
535d6c4e77
commit
b19f150725
35
Assets/Scripts/PlayerList.cs
Normal file
35
Assets/Scripts/PlayerList.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class PlayerList : MonoBehaviour {
|
||||||
|
HashSet<int> playerIds = new();
|
||||||
|
TMP_Text text;
|
||||||
|
|
||||||
|
void Awake() {
|
||||||
|
text = GetComponent<TMP_Text>();
|
||||||
|
text.text = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPlayerList(IEnumerable<int> ids) {
|
||||||
|
playerIds.Clear();
|
||||||
|
foreach (int id in ids)
|
||||||
|
playerIds.Add(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Connected(int id) {
|
||||||
|
playerIds.Add(id);
|
||||||
|
UpdateList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Disconnected(int id) {
|
||||||
|
playerIds.Remove(id);
|
||||||
|
UpdateList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateList() {
|
||||||
|
text.text = "";
|
||||||
|
foreach (int playerId in playerIds)
|
||||||
|
text.text += $"Player #{playerId}\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/PlayerList.cs.meta
Normal file
11
Assets/Scripts/PlayerList.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8f4454c6a8ff1f5478829232f04817a5
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
x
Reference in New Issue
Block a user