using UnityEngine; using TMPro; public class CollectManager : MonoBehaviour { public static CollectManager Instance; [Header("进度设置")] public int totalChests = 3; private int collectedChests = 0; [Header("UI 关联")] public TMP_Text progressText; void Awake() { Instance = this; } void Start() { UpdateUI(); } public void CollectChest() { collectedChests++; collectedChests = Mathf.Min( collectedChests, totalChests ); UpdateUI(); Debug.Log( "收集宝箱:" + collectedChests + "/" + totalChests ); } // 判断是否全部收集完成 public bool IsAllCollected() { return collectedChests >= totalChests; } void UpdateUI() { if (progressText != null) progressText.text = collectedChests + "/" + totalChests; } }