using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class Coiner : MonoBehaviour { public delegate void EventHandler(); public static event EventHandler Increaser; public TextMeshProUGUI coinText; private void Start() { IncreaseCoin(); //EventManager.CoinIncreaser += IncreaseCoin; } void OnEnable() { IncreaseCoin(); EventManager.CoinIncreaser += IncreaseCoin; Debug.Log("OnEnabler Caller"); } private void OnDisable() { IncreaseCoin(); EventManager.CoinIncreaser -= IncreaseCoin; } private void OnApplicationQuit() { Debug.Log("OnApplicationQuit"); EventManager.CoinIncreaser -= IncreaseCoin; } void IncreaseCoin() { coinText.text = PlayerPrefs.GetInt("Money").ToString(); } }