using Dreamteck.Splines; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; public class SplineTrigger : MonoBehaviour { [SerializeField] private LayerMask _layerMask; [SerializeField] private bool _triggerOnce = true; private bool _triggered = false; public UnityEvent OnTriggerEvent; public UnityEvent OnTriggerStayEvent; private void OnTriggerEnter(Collider other) { if (_triggerOnce && _triggered) return; if ((_layerMask.value & (1 << other.transform.gameObject.layer)) > 0) { if (_triggerOnce) _triggered = true; OnTriggerEvent?.Invoke(other); } } private void OnTriggerStay(Collider other) { if (_triggerOnce && _triggered) return; if ((_layerMask.value & (1 << other.transform.gameObject.layer)) > 0) { if (_triggerOnce) _triggered = true; OnTriggerStayEvent?.Invoke(other); } } }