예제 #1
0
        void Awake()
        {
            upPressed    = new UnityEventWrapper <bool>();
            downPressed  = new UnityEventWrapper <bool>();
            leftPressed  = new UnityEventWrapper <bool>();
            rightPressed = new UnityEventWrapper <bool>();

            spacePressed = new UnityEvent();
            zPressed     = new UnityEvent();
        }
예제 #2
0
        public static void StartListening <T, U>(string eventName, UnityAction <T, U> listener)
        {
            UnityEventBase thisEvent = null;

            if (Instance.eventDictionary.TryGetValue(eventName, out thisEvent))
            {
                ((UnityEvent <T, U>)thisEvent).AddListener(listener);
            }
            else
            {
                thisEvent = new UnityEventWrapper <T, U>();
                ((UnityEvent <T, U>)thisEvent).AddListener(listener);
                Instance.eventDictionary.Add(eventName, thisEvent);
            }
        }
예제 #3
0
        public static void StartListening <T>(string eventName, UnityAction <T> listener)
        {
            string log = "Start listenning";

            UnityEventBase thisEvent = null;

            if (Instance.eventDictionary.TryGetValue(eventName, out thisEvent))
            {
                log += " again";
                ((UnityEvent <T>)thisEvent).AddListener(listener);
            }
            else
            {
                thisEvent = new UnityEventWrapper <T>();
                ((UnityEvent <T>)thisEvent).AddListener(listener);
                Instance.eventDictionary.Add(eventName, thisEvent);
            }

            log += " to " + eventName + ".";
            Debug.Log(log);
        }