RandomGFGoStop/Assets/Scripts/UI/KeySynchronizer.cs

32 lines
694 B
C#

using UnityEngine;
public class KeySynchronizer : MonoBehaviour
{
private TMPro.TextMeshProUGUI tmp;
private void Awake()
{
tmp = this.GetComponent<TMPro.TextMeshProUGUI>();
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();
}
}