/// <summary> /// Subscribe to an event with a callback. This removes all previous subscriptions for this event. /// </summary> /// <param name="callback"></param> /// <param name="type"></param> public static void OverrideSubscription(EventDataCallback callback, Component component, EventType type) { CallbackComponentPair pair = new CallbackComponentPair(callback, component); ComponentEventsContainer cont = new ComponentEventsContainer(); cont.AddPair(pair); componentEventsData.Add(type, cont); }
/// <summary> /// Subscribe to an event with a callback from a component. The subscription is removed automatically when the component is destroyed. /// </summary> /// <param name="callback"></param> /// <param name="component"></param> /// <param name="type"></param> public static void SubscribeToEvent(EventDataCallback callback, Component component, EventType type) { CallbackComponentPair pair = new CallbackComponentPair(callback, component); if (!componentEventsData.ContainsKey(type)) { ComponentEventsContainer cont = new ComponentEventsContainer(); cont.AddPair(pair); componentEventsData.Add(type, cont); } else { componentEventsData[type].AddPair(pair); } }