public static void SetListenerActive <E, F>(this UnityEvent <E, F> thisEvent, UnityAction <E, F> listener, bool active) { if (active) { thisEvent.AddListenerOnce(listener); } else { thisEvent.RemoveListener(listener); } }