using UnityEngine; using UnityEngine.UI; public class CoinManager : MonoBehaviour { public static CoinManager instance; public Text coinText; private int coinCount; private void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } } private void Start() { ResetCoins(); } public void AddCoin(int amount) { coinCount += amount; UpdateCoinUI(); } public void ResetCoins() { coinCount = 0; UpdateCoinUI(); } private void UpdateCoinUI() { coinText.text = coinCount.ToString(); } }