public bool OpenWindow(UIWinID winID) { if (winID >= UIWinID.UI_None) { return(false); } UIWin win = null; m_cacheUIs.TryGetValue(winID, out win); if (win == null) { UnityEngine.GameObject ui = _LoadUIPrefab(winID); if (ui != null) { win = ui.GetComponent <UIWin>(); m_cacheUIs.Add(winID, win); Log.Info("cache ui:{0}", winID); } } else { win.gameObject.SetActive(true); } win.OnOpen(); return(true); }
private UnityEngine.GameObject _LoadUIPrefab(UIWinID winID) { string UIpath = string.Format("{0}/{1}/{2}", "ArtWorks", "UI", winID.ToString()); UnityEngine.Object prefab = Resources.Load(UIpath); GameObject inst = GameObject.Instantiate(prefab) as GameObject; if (inst == null) { Log.Info("Load UIPrefab failed: {0}", UIpath); } return(inst); }
public void CloseWindow(UIWinID winID, bool destory = false) { UIWin win = null; m_cacheUIs.TryGetValue(winID, out win); if (win == null) { return; } win.gameObject.SetActive(false); win.OnClose(); if (destory == true) { m_cacheUIs.Remove(winID); GameObject.Destroy(win.gameObject); } }