Files
2026-03-17 13:40:09 +02:00

54 lines
1.1 KiB
C#

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<SecretInfoManager>();
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}";
}
}
}