using UnityEngine; public class GoldSynchronizer : MonoBehaviour { [SerializeField] private bool UseConvertToString = true; private TMPro.TextMeshProUGUI tmp; private void Awake() { tmp = this.GetComponent(); if (GameManager.Instance != null) { GameManager.Event.RegistEvent(EEventType.OnSynchronizeGold, this.OnSynchronizeGold); } this.OnSynchronizeGold(); } private void OnDestroy() { if (GameManager.Instance != null) { GameManager.Event.RemoveEvent(EEventType.OnSynchronizeGold, this.OnSynchronizeGold); } } private void OnSynchronizeGold() { if (UseConvertToString) tmp.text = CodeJay.CodeJayUtility.Converter.MoneyToString(GameManager.DB.Gold); else tmp.text = GameManager.DB.Gold.ToString(); } }