/// <summary> /// Gets the total event count (sum of runtime and persistent events). Beware this is a hack using reflection. /// </summary> public int GetTotalEventCount() { if (!UnityEventReflection.TryAccessCalls(this, ref _callsObject)) { return(0); } return(UnityEventReflection.GetEventCount(_callsObject) + GetPersistentEventCount()); }
/// <summary> /// Removes a persistent listener. Beware this is a hack using reflection. /// </summary> public void RemovePersistentListener(UnityAction <T, U, V, X> action) { if (!UnityEventReflection.TryAccessPersistentCalls(this, ref _persistentCallsObject)) { return; } UnityEventReflection.RemovePersistentListener(_persistentCallsObject, action.Target as UnityEngine.Object, action.Method); }
/// <summary> /// Adds a persistent listener. Beware this is a hack using reflection. /// </summary> public void AddPersistentListener(UnityAction action) { if (!UnityEventReflection.TryAccessPersistentCalls(this, ref _persistentCallsObject)) { return; } int index = GetPersistentEventCount(); UnityEventReflection.AddPersistentListner(_persistentCallsObject, index, action.Target as UnityEngine.Object, action.Method); }
/// <summary> /// Adds a persistent listener. Beware this is a hack using reflection. /// </summary> public void AddPersistentListener(UnityAction <T, U, V, X> action, UnityEventCallState state = UnityEventCallState.RuntimeOnly) { if (!UnityEventReflection.TryAccessPersistentCalls(this, ref _persistentCallsObject)) { return; } int index = GetPersistentEventCount(); UnityEventReflection.AddPersistentListner(_persistentCallsObject, index, action.Target as UnityEngine.Object, action.Method); SetPersistentListenerState(index, state); }
public static void AddPersistentListener <T0, T1, T2, T3>(this UnityEvent <T0, T1, T2, T3> e, UnityAction <T0, T1, T2, T3> action) { object persistentCallsObject = null; if (!UnityEventReflection.TryAccessPersistentCalls(e, ref persistentCallsObject)) { return; } int index = e.GetPersistentEventCount(); UnityEventReflection.AddPersistentListner(persistentCallsObject, index, action.Target as UnityEngine.Object, action.Method); }