using System; using UnityEngine; namespace ZC { public class TriggerEvent : MonoBehaviour { [SerializeField] private string targetName; private Action callback; private void Awake() { gameObject.SetActive(false); } private void OnTriggerEnter(Collider other) { if (other.name == targetName) { callback?.Invoke(); } } public void SetData(Action callback, string target = "Player") { gameObject.SetActive(true); this.targetName = target; this.callback = callback; } public void Dispose() { gameObject.SetActive(false); } } }