/// <summary> /// 关闭,但不销毁一个OpenedUIs中的UI /// </summary> /// <param name="ui"></param> public void CloseUI(UIEnum ui) { if (OpenedUIs.ContainsKey(ui)) { OpenedUIs[ui].SetActive(false); } }
public GameObject OpenUI(UIEnum ui) { GameObject uiNode; //如果当前已打开过的UI列表有,则重新打开 if (OpenedUIs.TryGetValue(ui, out uiNode)) { uiNode.gameObject.SetActive(true); return(uiNode); } //否则从Prefebs中加载 else { string path = string.Format("Prefabs/UI/{0}", ui.ToString()); GameObject UI = Resources.Load(path) as GameObject; uiNode = Instantiate(UI, UIRoot); // uiNode.SetActive(false); OpenedUIs.Add(ui, uiNode); return(uiNode); } }