public void RemovePopupAndParentCanvas(BaseSceneEaseInOut panel) { if (panel == null) { return; } panel.Dispose(); Canvas canvas = panel.transform.parent.GetComponent <Canvas>(); if (canvas != null) { GameObject.Destroy(canvas.gameObject); } }
//找到所有ID为StrId的弹窗,并将之销毁 public bool RemovePopup(string strId) { if (connectFailedDialogId == strId) { Debug.Log("Try Remove connectFailedDialog,Failed!"); return(false); } //找到所有ID为StrId的弹窗,并将之销毁 List <GameObject> objs = new List <GameObject>(); //在uiLayerPopUps队列以及uiLayerPopUps里面GameObj的子弹窗里面找 for (int idx = 0; idx < uiLayerPopUps.Count; ++idx) { if (uiLayerPopUps[idx].strId == strId) { objs.Add(uiLayerPopUps[idx].gameObj); for (int idx2 = 0; idx2 < uiLayerPopUps[idx].childObjs.Count; ++idx2) { if (uiLayerPopUps[idx].childObjs[idx2].strId == strId) { objs.Add(uiLayerPopUps[idx].childObjs[idx2].gameObj); } } } } //在popLayerPopUps队列以及popLayerPopUps里面GameObj的子弹窗里面找 for (int idx = 0; idx < popLayerPopUps.Count; ++idx) { if (popLayerPopUps[idx].strId == strId) { objs.Add(popLayerPopUps[idx].gameObj); for (int idx2 = 0; idx2 < popLayerPopUps[idx].childObjs.Count; ++idx2) { if (popLayerPopUps[idx].childObjs[idx2].strId == strId) { objs.Add(popLayerPopUps[idx].childObjs[idx2].gameObj); } } } } if (objs.Count == 0) { return(false); } //销毁掉所有的这些弹窗 for (int idx = 0; idx < objs.Count; ++idx) { BaseSceneEaseInOut baseScene = objs[idx].GetComponent <BaseSceneEaseInOut>(); if (baseScene != null) { baseScene.Dispose(); } } return(true); }