Пример #1
0
    void Start()
    {
        myEvent = new UnityEvent();
        myEvent.AddListener(FireFunction);
        myEvent.AddListener(AnotherFireFunction);

        paramsEvent = new ParamsEvent();
        paramsEvent.AddListener(FireFunctionWithParams);

        myEvent.Invoke();
        paramsEvent.Invoke("hello", 22);
        paramsEvent.Invoke("jdawgs", 8008135);
    }
Пример #2
0
        public static void TriggerEvent(string eventName, ParamsObject paramsObj = null)
        {
            ParamsEvent thisEvent = null;

            if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
            {
                thisEvent.Invoke(paramsObj);
            }

            if (instance.lastEventValues != null)
            {
                instance.lastEventValues[eventName] = paramsObj;
            }
        }
Пример #3
0
        public void TriggerEvent(string eventName, ParamsObject paramsObj = null)
        {
            if (eventDictionary == null)
            {
                eventDictionary = new Dictionary <string, ParamsEvent>();
                lastEventValues = new Dictionary <string, ParamsObject>();
            }

            ParamsEvent thisEvent = null;

            if (eventDictionary.TryGetValue(eventName, out thisEvent))
            {
                thisEvent.Invoke(paramsObj);
                lastEventValues[eventName] = paramsObj;
            }
        }