private void OnDestroy() { OnBeforeDestroy(); foreach (var msgRecord in _mMsgRecorder) { MsgDispatcher.UnRegister(msgRecord.Name, msgRecord.OnMsgReceived); msgRecord.Recycle(); } _mMsgRecorder.Clear(); }
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"); }
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(); }