Пример #1
0
 /// <summary>
 /// Registers an event listener.
 /// </summary>
 /// <param name="injection">The event listener info.</param>
 public static void RegisterEvent(EventInjection injection)
 {
     HashSet<EventInjection> listeners;
     if (!eventMap.TryGetValue(injection.inject.Name, out listeners)) {
         listeners = new HashSet<EventInjection>();
         eventMap.Add(injection.inject.Name, listeners);
     }
     listeners.Add(injection);
 }
Пример #2
0
 private static void FireEvent(EventInjection injection, object[] args)
 {
     MonoBehaviour component = injection.component;
     MethodInfo method = injection.method;
     try {
         object result = method.Invoke(component, args);
         // Allow for Unity style coroutines to be used
         if (result is IEnumerator) {
             component.StartCoroutine((IEnumerator)result);
         }
     } catch (System.Exception e) {
         Debug.LogError(injection);
         Debug.LogError(e);
     }
 }
Пример #3
0
 /// <summary>
 /// Unregisters an event listener.
 /// </summary>
 /// <param name="injection">The event listener info.</param>
 public static void UnregisterEvent(EventInjection injection)
 {
     HashSet<EventInjection> listeners;
     if (eventMap.TryGetValue(injection.inject.Name, out listeners)) {
         listeners.Remove(injection);
     }
 }