using TMPro; using UnityEngine; // 곡 종료 후 결과창. 총점/판정수/정확도/등급/최대콤보를 표시한다. public class RhythmResultHud : MonoBehaviour { [SerializeField] private RhythmManager _manager; [SerializeField] private GameObject _root; // 결과창 루트 [SerializeField] private TMP_Text _scoreText; [SerializeField] private TMP_Text _maxComboText; [SerializeField] private TMP_Text _countText; // Perfect/Good/Bad/Miss 모아서 표시 private void Awake() { if (_root != null) _root.SetActive(false); } private void OnEnable() { if (_manager == null) return; _manager.OnSongStarted += Hide; _manager.OnSongFinished += Show; } private void OnDisable() { if (_manager == null) return; _manager.OnSongStarted -= Hide; _manager.OnSongFinished -= Show; } private void Hide() { if (_root != null) _root.SetActive(false); // 곡 시작/재시작 시 이전 결과창 숨김 } private void Show(RhythmScore score) { if (_scoreText != null) _scoreText.text = $"{score.Score:N0}"; if (_maxComboText != null) _maxComboText.text = $"{score.MaxCombo}"; if (_countText != null) _countText.text = $"Perfect {score.PerfectCount}\n" + $"Good {score.GoodCount}\n" + $"Bad {score.BadCount}\n" + $"Miss {score.MissCount}"; if (_root != null) _root.SetActive(true); } }