Exemple #1
0
    public static void StopListening(string eventName, UnityAction <Args> listener)
    {
        UnityCustomEvents <Args> thisEvent = null;

        if (eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.RemoveListener(listener);
        }
    }
Exemple #2
0
    public static void TriggerEvent(string eventName, Args args = null)
    {
        if (args == null)
        {
            args = new Args();
        }
        UnityCustomEvents <Args> thisEvent = null;

        if (eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(args);
        }
    }
Exemple #3
0
    public static void StartListening(string eventName, UnityAction <Args> listener)
    {
        if (listener == null)
        {
            return;
        }
        UnityCustomEvents <Args> thisEvent = null;

        if (eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.AddListener(listener);
        }
        else
        {
            thisEvent = new UnityCustomEvents <Args>();
            thisEvent.AddListener(listener);
            eventDictionary.Add(eventName, thisEvent);
        }
    }