using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class SecretInfoZone : MonoBehaviour { [SerializeField] private TextMeshProUGUI _localProgressText; private SecretInfoManager _manager; void Start() { _manager = FindObjectOfType(); if (_manager == null) { return; } if (_localProgressText != null) { _manager.OnProgressChanged += UpdateLocalText; UpdateLocalText(_manager.CollectedCount, _manager.TotalCount); } } void OnDestroy() { if (_manager != null && _localProgressText != null) { _manager.OnProgressChanged -= UpdateLocalText; } } void OnTriggerEnter(Collider other) { _manager?.ObjectEntered(other.gameObject); } void OnTriggerExit(Collider other) { _manager?.ObjectExited(other.gameObject); } private void UpdateLocalText(int collected, int total) { if (_localProgressText != null) { _localProgressText.text = $"{collected}/{total}"; } } }