using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; public class CoinCounter : MonoBehaviour { [SerializeField] private int _coinCount; public event UnityAction OnValueChanged; public int CoinCount => _coinCount; public void CollectCoin() { _coinCount++; OnValueChanged?.Invoke(_coinCount); } }