private void OnEnable() { if (!enabled) { return; } if (eventResponsePairs == null) { return; } for (int i = 0; i < eventResponsePairs.Length; i++) { EventResponsePair e = eventResponsePairs[i]; if (e.Event == null || e.Event.EventListeners == null || e.Event.EventListeners.Contains(this)) { continue; } if (e.Event != null) { e.Event.RegisterListener(this); } } }
public void OnEventRaised <T0, T1, T2, T3>(GameEventBase e, T0 arg0, T1 arg1, T2 arg2, T3 arg3) { for (int i = 0; i < eventResponsePairs.Length; i++) { EventResponsePair eventResponsePair = eventResponsePairs[i]; if (e.Equals(eventResponsePair.Event)) { eventResponsePair.LogToConsoleIfEnabled(this); eventResponsePair.Invoke(arg0, arg1, arg2, arg3); } } }
/// <summary> /// Invokes listeners if their event's name matches the name of the passed argument. /// </summary> /// <param name="e">Target event.</param> public void OnEventRaised(GameEventBase e) { for (int i = 0; i < eventResponsePairs.Length; i++) { EventResponsePair eventResponsePair = eventResponsePairs[i]; if (e.Equals(eventResponsePair.Event)) { eventResponsePair.LogToConsoleIfEnabled(this); eventResponsePair.Invoke(); } } }
private void OnValidate() { if (eventResponsePairs != null) { for (int i = 0; i < eventResponsePairs.Length; i++) { EventResponsePair e = eventResponsePairs[i]; if (e != null) { e.OnValidate(); } } } }
private void OnDisable() { if (eventResponsePairs == null) { return; } for (int i = 0; i < eventResponsePairs.Length; i++) { EventResponsePair e = eventResponsePairs[i]; if (e.Event != null) { e.Event.UnregisterListener(this); } } }