using UdonSharp; using UnityEngine; using UnityEngine.SocialPlatforms.Impl; using UnityEngine.UI; using VRC.SDKBase; using VRC.Udon; public class ScoreboardRowSpawner : Scoreboard { public GameObject rowPrefab; public Transform rowContainer; public override void UpdateScoreboard() { // Clear existing rows foreach (Transform child in rowContainer) { Destroy(child.gameObject); } // Spawn new rows based on player data VRCPlayerApi[] players = playerManager.GetCurrentPlayers(); foreach (VRCPlayerApi player in players) { GameObject newRow = Instantiate(rowPrefab, rowContainer); Debug.Log("Spawning scoreboard row for player: " + player.displayName); // Get all TMP_Text components from the children TMPro.TMP_Text[] textComponents = newRow.GetComponentsInChildren(); // Set the first TMP_Text to the player's display name if (textComponents.Length > 0) { textComponents[0].text = player.displayName; } // Set the second TMP_Text to the player's score if (textComponents.Length > 1) { textComponents[1].text = playerManager.GetScore(player.playerId).ToString(); } // 3. Set the Background Color // We get the Image component from the root of the prefab Image backgroundComponent = newRow.GetComponent(); if (backgroundComponent != null) { backgroundComponent.color = playerManager.GetTeam(player.playerId) == "red" ? new Color(1f, 0f, 0f, 0.5f) : playerManager.GetTeam(player.playerId) == "blue" ? new Color(0f, 0f, 1f, 0.5f) : new Color(0.5f, 0.5f, 0.5f, 0.5f); } } } }