public GameObject ShowPanel(EUIPanel eUIPanel) { if (curUIPanels.ContainsKey(eUIPanel)) { GameObject panel = curUIPanels[eUIPanel]; if (panel != null && !panel.activeSelf) { panel.SetActive(true); } return(curUIPanels[eUIPanel]); } string panelName = string.Format("UIPanel/{0}", eUIPanel.ToString()); //枚举名与Resources下文件名 一致 GameObject uiPanel = GameObject.Instantiate(Resources.Load <GameObject>(panelName)); Canvas canvas = uiPanel.GetComponent <Canvas>(); if (canvas == null) { uiPanel.transform.SetParent(transform, false); } curUIPanels.Add(eUIPanel, uiPanel); uiPanel.gameObject.SetActive(true); return(uiPanel); }
public GameObject GetPanel(EUIPanel eUIPanel) { if (!curUIPanels.ContainsKey(eUIPanel)) { #if UNITY_EDITOR Debug.LogWarning(" GetPanel Error ! No " + eUIPanel); #endif return(null); } return(curUIPanels[eUIPanel]); }
public bool DisablePanel(EUIPanel eUIPanel) { if (!curUIPanels.ContainsKey(eUIPanel)) { #if UNITY_EDITOR Debug.LogWarning(" GetPanel Error ! No " + eUIPanel); #endif return(false); } curUIPanels[eUIPanel].SetActive(false); return(true); }
public void ClosePanel(EUIPanel eUIPanel) { if (!curUIPanels.ContainsKey(eUIPanel)) { #if UNITY_EDITOR Debug.LogWarning(" 该UI界面 不存在 ! No " + eUIPanel); #endif return; } //TODO 可以考虑 延迟5秒销毁 GameObject.Destroy(curUIPanels[eUIPanel]); curUIPanels.Remove(eUIPanel); }