Initial commit
This commit is contained in:
53
Assets/Materials/Scripts/SecretInfoZone.cs
Normal file
53
Assets/Materials/Scripts/SecretInfoZone.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user