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