示例#1
0
文件: B.cs 项目: diviner69/U3D
        private IEnumerator Start()
        {
            MsgDispatcher.Send("Do", "你好");
            yield return(new WaitForSeconds(3f));

            MsgDispatcher.Send("Do", "你好呀,哈哈");
        }
示例#2
0
文件: B.cs 项目: diviner69/U3D
 void OnDestroy()
 {
     OnBeforeDestroy();
     foreach (var msgRecord in mMsgRecords)
     {
         MsgDispatcher.UnRegister(msgRecord.Name, msgRecord.OnMysgReceived);
         msgRecord.Recycle();
     }
 }
示例#3
0
        private static void MenuClicked()
        {
            MsgDispatcher.UnRegisterAll("Do");
            MsgDispatcher.UnRegisterAll("OK");

            UnityEditor.EditorApplication.isPlaying = true;

            new GameObject("MsgReceiverObj")
            .AddComponent <FrameworkExample>();
        }
        private static void MenuClicked()
        {
            MsgDispatcher.UnRegisterAll("Message_1");
            MsgDispatcher.Register("Message_1", OnMsgReceived);
            MsgDispatcher.Register("Message_1", OnMsgReceived);

            MsgDispatcher.Send("Message_1", "hello world");

            MsgDispatcher.UnRegister("Message_1", OnMsgReceived);
            MsgDispatcher.Send("Message_1", "hello");
        }
示例#5
0
        private IEnumerator Start()
        {
            MsgDispatcher.Send("Do", "hello");

            yield return(new WaitForSeconds(1.0f));

            MsgDispatcher.Send("Do", "hello1");

            SendMsg("OK", "hello");
            SendMsg("OK", "hello");
        }
        protected void UnRegisterMsg(string msgName)
        {
            var selectedRecords = mMsgRecorder.FindAll(recorder => recorder.Name == msgName);

            selectedRecords.ForEach(selectRecord =>
            {
                MsgDispatcher.UnRegister(selectRecord.Name, selectRecord.OnMsgReceived);
                mMsgRecorder.Remove(selectRecord);
            });

            selectedRecords.Clear();
        }
        private void OnDestroy()
        {
            OnBeforeDestroy();

            foreach (var msgRecord in mMsgRecorder)
            {
                MsgDispatcher.UnRegister(msgRecord.Name, msgRecord.OnMsgReceived);
                msgRecord.Recycle();
            }

            mMsgRecorder.Clear();
        }
示例#8
0
        public void UnRegisterMsg(string msgName)
        {
            var selectedRecords =
                mMsgRecords.FindAll(record => record.Name == msgName);

            selectedRecords.ForEach(record =>
            {
                MsgDispatcher.UnRegister(record.Name, record.OnMysgReceived);
                mMsgRecords.Remove(record);
                record.Recycle();
            });
            selectedRecords.Clear();
        }
示例#9
0
        private static void MenuClicked()
        {
            // 全部清空,确保测试有效
            MsgDispatcher.UnRegisterAll("消息1");

            MsgDispatcher.Register("消息1", OnMsgReceived);
            MsgDispatcher.Register("消息1", OnMsgReceived);

            MsgDispatcher.Send("消息1", "hello world");

            MsgDispatcher.UnRegister("消息1", OnMsgReceived);

            MsgDispatcher.Send("消息1", "hello");
        }
        protected void UnRegisterMsg(string msgName, Action <object> onMsgRecevived)
        {
            var selectedRecords = m_MsgRegisterRecorder.FindAll(recorder =>
                                                                recorder.MsgName == msgName &&
                                                                recorder.OnMsgReceived == onMsgRecevived);

            selectedRecords.ForEach(selectedRecord =>
            {
                MsgDispatcher.UnRegister(selectedRecord.MsgName, selectedRecord.OnMsgReceived);
                m_MsgRegisterRecorder.Remove(selectedRecord);
            });

            selectedRecords.Clear();
        }
示例#11
0
 public static void SendMsg(string msgName, object data)
 {
     MsgDispatcher.Send(msgName, data);
 }
示例#12
0
文件: B.cs 项目: diviner69/U3D
 public void RegisterMsg(string msgName, Action <object> onMsgReceived)
 {
     MsgDispatcher.Register(msgName, onMsgReceived);
     //   mMsgRegisterRecorder.Add(msgName, onMsgReceived);
     mMsgRecords.Add(MsgRecord.Allocate(msgName, onMsgReceived));
 }
 protected void SendMsg(string msgName, object data)
 {
     MsgDispatcher.Send(msgName, data);
 }
        protected void RegisterMsg(string msgName, Action <object> onMsgReceived)
        {
            MsgDispatcher.Register(msgName, onMsgReceived);

            m_MsgRegisterRecorder.Add(MsgRecord.Allocate(msgName, onMsgReceived));
        }