public void Remove(UIPanel ui) { if (ui != null && layerDic.ContainsKey(ui)) { UiLayer layer = layerDic[ui]; List <UIPanel> panelList = uiDic[layer]; int count = panelList.Count; if (count >= 2) { BaseUi baseUi = GetBaseUiByPanel(panelList[count - 2]); if (baseUi != null) { baseUi.RemoveOverlay(); } } uiDic[layer].Remove(ui); layerDic.Remove(ui); } }