private IEnumerator Start() { MsgDispatcher.Send("Do", "hello1"); yield return(new WaitForSeconds(1.0f)); MsgDispatcher.Send("Do", "hello2"); SendMsg("OK", "hello"); SendMsg("OK", "hello"); }
private static void MenuClicked() { MsgDispatcher.UnRegisterAll("Do"); MsgDispatcher.UnRegisterAll("OK"); UnityEditor.EditorApplication.isPlaying = true; new GameObject("MsgReceivedObj").AddComponent <FrameworkExample>(); }
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"); }
private void OnDestroy() { OnBeforeDestroy(); foreach (var msgRecord in _mMsgRecorder) { MsgDispatcher.UnRegister(msgRecord.Name, msgRecord.OnMsgReceived); msgRecord.Recycle(); } _mMsgRecorder.Clear(); }
public void UnRegisterMsg(string msgName) { var selectedRecords = _mMsgRecorder.FindAll(record => record.Name == msgName); selectedRecords.ForEach(record => { MsgDispatcher.UnRegister(record.Name, record.OnMsgReceived); _mMsgRecorder.Remove(record); record.Recycle(); }); selectedRecords.Clear(); }
public void SendMsg(string msgName, object data) { MsgDispatcher.Send(msgName, data); }
public void RegisterMsg(string msgName, Action <object> onMsgReceived) { MsgDispatcher.Register(msgName, onMsgReceived); _mMsgRecorder.Add(MsgRecord.Allocate(msgName, onMsgReceived)); }