public static bool simpleDispatch(this Component self, string type, object data = null)
        {
            MonoEventDispatcher dispatcher = self.GetComponent <MonoEventDispatcher>();

            if (dispatcher == null)
            {
                return(false);
            }
            return(dispatcher.simpleDispatch(type, data));
        }
        public static bool hasEventListener(this Component self, string type)
        {
            MonoEventDispatcher dispatcher = self.GetComponent <MonoEventDispatcher>();

            if (dispatcher == null)
            {
                return(false);
            }
            return(dispatcher.hasEventListener(type));
        }
        public static bool dispatchEvent(this Component self, EventX e)
        {
            MonoEventDispatcher dispatcher = self.GetComponent <MonoEventDispatcher>();

            if (dispatcher == null)
            {
                return(false);
            }
            return(dispatcher.dispatchEvent(e));
        }
Exemplo n.º 4
0
        public static void StopCoroutine(this GameObject self, Coroutine routine)
        {
            MonoEventDispatcher dispatcher = self.GetComponent <MonoEventDispatcher>();

            if (dispatcher == null)
            {
                dispatcher = self.AddComponent <MonoEventDispatcher>();
            }
            dispatcher.StopCoroutine(routine);
        }
Exemplo n.º 5
0
        public static Coroutine StartCoroutine(this GameObject self, IEnumerator routine)
        {
            MonoEventDispatcher dispatcher = self.GetComponent <MonoEventDispatcher>();

            if (dispatcher == null)
            {
                dispatcher = self.AddComponent <MonoEventDispatcher>();
            }
            return(dispatcher.StartCoroutine(routine));
        }
Exemplo n.º 6
0
        public static bool removeEventListener(this GameObject self, string type, Action <EventX> listener)
        {
            MonoEventDispatcher dispatcher = self.GetComponent <MonoEventDispatcher>();

            if (dispatcher == null)
            {
                return(false);
            }
            return(dispatcher.removeEventListener(type, listener));
        }
Exemplo n.º 7
0
        public static object GetData(this GameObject self)
        {
            MonoEventDispatcher dispatcher = self.GetComponent <MonoEventDispatcher>();

            if (dispatcher == null)
            {
                return(null);
            }
            return(dispatcher.data);
        }
        public static bool removeEventListener(this Component self, string type, Action <EventX> listener)
        {
#if UNITY_EDITOR
            ///编辑器直接退出时会有这种贱的调用
            if (self == null)
            {
                return(false);
            }
#endif
            MonoEventDispatcher dispatcher = self.GetComponent <MonoEventDispatcher>();
            if (dispatcher == null)
            {
                return(false);
            }
            return(dispatcher.removeEventListener(type, listener));
        }
        public static bool addEventListener(this Component self, string type, Action <EventX> listener, int priority = 0)
        {
            MonoEventDispatcher dispatcher = self.gameObject.GetOrAddComponent <MonoEventDispatcher>();

            return(dispatcher.addEventListener(type, listener, priority));
        }
Exemplo n.º 10
0
        public static void SetData(this GameObject self, object value)
        {
            MonoEventDispatcher dispatcher = self.GetOrAddComponent <MonoEventDispatcher>();

            dispatcher.data = value;
        }