rabidus-test/Assets/Scripts/CoinCounter.cs

20 lines
400 B
C#

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