using UnityEngine; using UnityEngine.Events; /// /// To use a generic UnityEvent type you must override the generic type. /// [System.Serializable] public class IntEvent : UnityEvent { } /// /// A flexible handler for int events in the form of a MonoBehaviour. Responses can be connected directly from the Unity Inspector. /// public class IntEventListener : MonoBehaviour { [SerializeField] private IntEventChannelSO _channel = default; public IntEvent OnEventRaised; private void OnEnable() { if (_channel != null) _channel.OnEventRaised += Respond; } private void OnDisable() { if (_channel != null) _channel.OnEventRaised -= Respond; } private void Respond(int value) { if (OnEventRaised != null) OnEventRaised.Invoke(value); } }