public void DestroyUI(UIName ui_name) { int i_ui_name = (int)ui_name; if (!m_loaded_prefab.ContainsKey(i_ui_name)) { return; } m_loaded_prefab.Remove(i_ui_name); Debug.Log("UIPrefabMgr DestroyUI, " + UIRegister.UI_DIR + ui_name.ToString()); }
public T Open <T>(UIName uiName) where T : UIBase { if (!m_uiDic.ContainsKey(uiName)) { T prefabs = Resources.Load <T>("UI/" + uiName.ToString()); if (prefabs == null) { return(null); } T obj = Instantiate <T>(prefabs); m_uiDic.Add(uiName, obj.Init()); obj.Open(); obj.transform.SetParent(transform); return(obj); } else { m_uiDic[uiName].Open(); return(m_uiDic[uiName] as T); } }
public void ShowWindow(UIName _uiName, object o) { if (m_CurrentWindow != null) { m_LastWindow = m_CurrentWindow.m_UIName; m_CurrentWindow.LeaveWindow(); } string kPath = GameManager.m_PathManager.ReturnPath(ResourcsePath.Prefab, PrefabPath.Window); m_Window = Instantiate <GameObject>(Resources.Load <GameObject>(kPath + _uiName.ToString()), GetCanvas().transform); m_CurrentWindow = m_Window.GetComponent <UIWindow>(); m_CurrentWindow.EnterWindow(o); }
void hideScreen(UIName id) { PowerUI.UI.document.getElementById(id.ToString()).style.display = "none"; }
void showScreen(UIName id) { PowerUI.UI.document.getElementById(id.ToString()).style.display = "block"; }
public T ToUI <T>(UIName uiName) where T : UIBase { UIBase TempUI; m_OpenedUIs.TryGetValue(uiName, out TempUI); T ui = TempUI as T; if (TempUI == null) { GameObject uiObj = Mgr_AssetBundle.Instance.LoadAsset <GameObject>(ABTypes.prefab, uiName.ToString()); ui = Instantiate(uiObj).GetComponent <T>(); ui.Init(); switch (ui.m_Type) { case UIType.Window: ui.transform.SetParent(GameManager.Instance.m_MainUI.m_Sorts[0], false); break; case UIType.PopUp: ui.transform.SetParent(GameManager.Instance.m_MainUI.m_Sorts[1], false); break; case UIType.Icon: ui.transform.SetParent(GameManager.Instance.m_MainUI.m_Sorts[2], false); break; } m_OpenedUIs.Add(uiName, ui); } if (ui.m_Type.Equals(UIType.Window)) { List <UIName> CloseList = new List <UIName>(); foreach (var item in m_OpenedUIs.Values) { if (item.m_Type.Equals(UIType.PopUp)) { CloseList.Add(item.m_UIName); } } foreach (var item in CloseList) { UIBase desUi; if (!m_OpenedUIs.TryGetValue(item, out desUi)) { continue; } if (!desUi.m_IsCache) { RemoveOpenedUI(uiName); } desUi.OnClose(); } } ui.OnOpen(); if (ui.m_Type.Equals(UIType.Window)) { if (m_CurWindow != null && !m_CurWindow.m_UIName.Equals(ui.m_UIName)) { m_CurWindow.OnClose(); } m_CurWindow = ui; } return(ui); }
public void Back(UIName name) { base.Back(name.ToString()); }
public void Show(UIName name) { base.Show(name.ToString()); }
void hideScreen(UIName id){ PowerUI.UI.document.getElementById(id.ToString()).style.display = "none"; }
void showScreen(UIName id){ PowerUI.UI.document.getElementById(id.ToString()).style.display = "block"; }
public void LoadUI(UIName ui_name, Action <IUIBase, object> on_load, string ui_dir_path = "", object data = null) { int i_ui_name = (int)ui_name; KeyValuePair <GameObject, IUIBase> pair; if (m_loaded_prefab.TryGetValue(i_ui_name, out pair)) { if (on_load != null) { on_load(pair.Value, data); } return; } string str_ui_name = ui_name.ToString(); string ui_prefab_path = UIRegister.UI_DIR + ui_dir_path + str_ui_name; GameObject prefab = Resources.Load(ui_prefab_path, typeof(GameObject)) as GameObject; if (prefab == null) { Debug.LogError("UIPrefabMgr LoadUI fail prefab, " + ui_prefab_path); if (on_load != null) { on_load(null, data); } return; } GameObject go = GameObject.Instantiate(prefab) as GameObject; if (go == null) { Debug.LogError("UIPrefabMgr LoadUI fail prefab, " + ui_prefab_path); if (on_load != null) { on_load(null, data); } return; } go.SetActive(false); // 等UIBase.Show()时再显示 UIBase ui_base = go.GetComponent <UIBase>(); if (ui_base == null) { Debug.LogError("UIPrefabMgr LoadUI fail prefab, " + ui_prefab_path); if (on_load != null) { on_load(null, data); } return; } Debug.Log("UIPrefabMgr LoadUI, " + ui_prefab_path); go.name = str_ui_name; // AssetBundle的名字 == 界面GameObject的名字 == 脚本的名字 Transform tf = go.transform; tf.SetParent(ui_base.GetUIParent()); //tf.parent = ; tf.localScale = Vector3.one; tf.localPosition = Vector3.zero; m_loaded_prefab[i_ui_name] = new KeyValuePair <GameObject, IUIBase>(go, ui_base); ui_base.Name = ui_name; // 成功 if (on_load != null) { on_load(ui_base, data); } }