This commit is contained in:
djkellerman
2025-03-25 22:37:28 -04:00
parent ad50ee6d7c
commit 02df7104d0
2 changed files with 19 additions and 6 deletions

View File

@@ -6,8 +6,9 @@ public class LeaderboardManager : MonoBehaviour
{
public static LeaderboardManager Instance { get; private set; }
[SerializeField] private GameObject playersParent; // The parent GameObject that holds the player icons
[SerializeField] private GameObject playerPrefab; // The prefab for the player icon
[SerializeField] private GameObject playersParent;
[SerializeField] private GameObject playerPrefab;
[SerializeField] private GameObject lifePrefab;
private Dictionary<GameObject, GameObject> playerIcons = new Dictionary<GameObject, GameObject>();
@@ -32,10 +33,10 @@ public class LeaderboardManager : MonoBehaviour
{
foreach (GameObject player in GameManager.players)
{
GameObject playerIcon = Instantiate(playerPrefab, playersParent.transform);
playerIcon.GetComponentInChildren<Text>().text = player.name;
playerIcon.GetComponentInChildren<Image>().color = GameManager.playerColors[GameManager.players.IndexOf(player)];
playerIcons[player] = playerIcon;
Transform parent = Instantiate(playerPrefab, playersParent.transform).transform;
GameObject life = Instantiate(lifePrefab, parent);
life.GetComponentInChildren<Image>().color = GameManager.playerColors[GameManager.players.IndexOf(player)];
playerIcons[player] = parent.gameObject;
}
}