using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; public class SimpleTrigger : MonoBehaviour { [SerializeField] private LayerMask _layerMask; public UnityEvent OnTriggerEnterEvent; public UnityEvent OnTriggerStayEvent; public UnityEvent OnTriggerExitEvent; private void OnTriggerEnter(Collider other) { if ((_layerMask.value & (1 << other.transform.gameObject.layer)) > 0) { OnTriggerEnterEvent?.Invoke(other); } } private void OnTriggerStay(Collider other) { if ((_layerMask.value & (1 << other.transform.gameObject.layer)) > 0) { OnTriggerStayEvent?.Invoke(other); } } private void OnTriggerExit(Collider other) { if ((_layerMask.value & (1 << other.transform.gameObject.layer)) > 0) { OnTriggerExitEvent?.Invoke(other); } } }