using UnityEngine; using System.Collections.Generic; public class PlayerTeamCashUI : MonoBehaviour { private readonly List teammates = new(); private void Start() { CashManager[] all = FindObjectsOfType(); foreach (CashManager cash in all) { TeamMember team = cash.GetComponent(); if (team == null) continue; if (team.CurrentTeam != TeamMember.Team.PlayerTeam) continue; if (cash.GetComponent() != null) continue; teammates.Add(cash); } } private void Update() { if (UI_Manager.Instance == null) return; if (teammates.Count > 0) UI_Manager.Instance.UpdateTeammate1Cash(teammates[0].currentCash); if (teammates.Count > 1) UI_Manager.Instance.UpdateTeammate2Cash(teammates[1].currentCash); } }