public static void TriggerEvent(GameData.Event eventName, GameObject obj, int firstValue, int secondValue) { UnityEventGameObject2Int thisEvent = null; if (Instance.eventDictionaryGameObject2Int.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(obj, firstValue, secondValue); } }
public static void StopListening(GameData.Event eventName, UnityAction <GameObject, int, int> listener) { if (EventManager.Instance == null) //au cas ou on a déja supprimé l'eventManager { return; } UnityEventGameObject2Int thisEvent = null; //si on veut unregister et que la clé existe dans le dico.. if (Instance.eventDictionaryGameObject2Int.TryGetValue(eventName, out thisEvent)) { thisEvent.RemoveListener(listener); } }
public static void StartListening(GameData.Event eventName, UnityAction <GameObject, int, int> listener) { if (!Instance) { return; } UnityEventGameObject2Int thisEvent = null; if (Instance.eventDictionaryGameObject2Int.TryGetValue(eventName, out thisEvent)) { thisEvent.AddListener(listener); } else { thisEvent = new UnityEventGameObject2Int(); thisEvent.AddListener(listener); Instance.eventDictionaryGameObject2Int.Add(eventName, thisEvent); } }