using UnityEngine; public class KeySynchronizer : MonoBehaviour { private TMPro.TextMeshProUGUI tmp; private void Awake() { tmp = this.GetComponent(); if (GameManager.Instance != null) { GameManager.Event.RegistEvent(EEventType.OnSynchronizeKey, this.OnSynchronizeKey); } this.OnSynchronizeKey(); } private void OnDestroy() { if (GameManager.Instance != null) { GameManager.Event.RemoveEvent(EEventType.OnSynchronizeKey, this.OnSynchronizeKey); } } private void OnSynchronizeKey() { tmp.text = GameManager.DB.Key.ToString(); } }