/// <summary> /// 给指定的Transform下的panel排序 /// 该panel的depth会记录 curMaxUIDepth 累加或递减 /// *** 默认 每个界面是有panel且都需要遮罩 《目前需求 》 /// </summary> /// <param name="transf">指定的Trans</param> /// <param name="startDepth">开始深度</param> /// <param name="isOut">是退出(true)还是加入(false)</param> private static void OrderChildPanel(UIOpenInfo data, int startDepth, bool isOut) { List <Canvas> panels = GetChildPanelList(data.UIObj.transform); if (panels == null || panels.Count <= 0) { return; } if (isOut) { startDepth -= depthInterval; curMaxUIDepth = startDepth - panels.Count; curMaxUIDepth = GetUpPanelMaxDepth(); } else { startDepth += depthInterval; panels.Sort((x, y) => { return(x.sortingOrder.CompareTo(y.sortingOrder)); }); for (int i = 0; i < panels.Count; ++i) { panels[i].sortingOrder = startDepth + (i + 1); } curMaxUIDepth = startDepth + panels.Count; } }
/// <summary> /// 往列表中添加已经打开的UI面板索引 /// </summary> private void UIOpenList_Add(UIOpenInfo uiInfo) { if (UIOpenList_Find(uiInfo.UIName) == null) { _UIOpenList.Add(uiInfo); } }
private void LoadUI(ref UIOpenInfo _info) { string uiPath = _info.UIPath; _info.UIObj = BasicsResLoad.Load <GameObject>(uiPath); OnLoadUIPrefabCallBack(ref _info); }
public void CloseUI(string _uiName, CloseType closeType = CloseType.DESTORY) { UIOpenInfo info = UIOpenList_Find(_uiName); if (info != null) { //把关闭的UI面板从链表里移除 //UIOpenList_Delete(info.UIName); switch (closeType) { case CloseType.DESTORY: //把关闭的UI面板从链表里移除 UIOpenList_Delete(info.UIName); _UIManager.CloseUI(info.UIName); break; case CloseType.HIDE: _UIManager.HideUI(info); break; } UIPanelDepthOrder.CloseChildPanelDep(info); } else { Debug.Log(" #[UICtrl-UIClose]# 该面板不存在 = " + _uiName); } }
/// <summary> /// 删除列表中的UI面板索引 /// </summary> private void UIOpenList_Delete(string uiName) { UIOpenInfo info = UIOpenList_Find(uiName); if (info != null) { _UIOpenList.Remove(info); } }
/// <summary> /// 加入panelDep 计算 /// </summary> public static void OpenChildPanelDep(UIOpenInfo uiData) { OrderChildPanel(uiData, curMaxUIDepth, false); /*if (curMaxUIDepth >= maxDepth) * { * resourceAllPannelDepth(); * }*/ resourceAllPannelDepth(); }
public UIOpenInfo UIStackPeekGetInfo(bool isBol = false) { UIOpenInfo info = null; for (int i = 1; i <= UIOpenList.Count; i++) { UIOpenInfo temp = UIOpenList[UIOpenList.Count - i]; info = temp; } return(info); }
/// <summary> /// 获取当前堆栈最上面的obj /// isBol=true 不要在乎黑片有没有,拿到列表里全部的界面 /// </summary> public GameObject UIStackPeekGet(bool isBol = false) { UIOpenInfo info = UIStackPeekGetInfo(isBol); if (info == null) { return(null); } else { return(info.UIObj); } }
public void OpenUI(ref UIOpenInfo _info) { if (UIMap.ContainsKey(_info.UIName)) { ShowUI(ref _info); } else if (UILoadList.IndexOf(_info.UIName) > 0) { return; } else { UILoadList.Add(_info.UIName); LoadUI(ref _info); } }
/// <summary> /// UI创建成功回调 /// </summary> public void C2CUIOpenCreatSucc(UIOpenInfo data) { if (data != null) { //当前UI面板添加进链表 UIOpenList_Add(data); if (data.UIObj != null) { //进行深度排序 UIPanelDepthOrder.OpenChildPanelDep(data); } } else { Debug.LogError(" #[UICtrl-C2CUIOpenCreatSucc]# 传递参数为空"); } }
public void CloseUI(string _name) { //顯示列表 if (UIShowMap.ContainsKey(_name)) { UIOpenInfo tmpUI = UIShowMap[_name]; GameObject.Destroy(tmpUI.UIObj); UnRegisterUI(_name); return; } //隱藏列表 if (UIHideDic.ContainsKey(_name)) { UIOpenInfo tmpUI = UIHideDic[_name]; GameObject.Destroy(tmpUI.UIObj); UnRegisterUI(_name); } }
private void ShowUI(ref UIOpenInfo _info) { if (UIMap.ContainsKey(_info.UIName)) { isHide = false; UIViewBase ui = UIMap[_info.UIName]; if (_info.UIObj == null) { _info.UIObj = ui.gameObject; } // 加入显示列表 if (!UIShowMap.ContainsKey(_info.UIName)) { UIShowMap.Add(_info.UIName, _info); UICtrl.Instance.C2CUIOpenCreatSucc(_info); } //清除隐藏列表 if (UIHideDic.ContainsKey(_info.UIName)) { UIHideDic.Remove(_info.UIName); ui.gameObject.SetActive(true); isHide = true; } try { //如果是隐藏界面显示 就不调用初始化了 if (isHide) { return; } ui.OnPushData(_info.ParamsVar); ui.Init(); ui.OnShow(); } catch (Exception e) { Debug.LogError("UI显示错误::" + e.ToString()); } } }
/// <summary> /// 隐藏UI /// </summary> /// <param name="uiName"></param> public void HideUI(UIOpenInfo _info) { if (!UIMap.ContainsKey(_info.UIName)) { return; } UIShowMap.Remove(_info.UIName); UIViewBase ui = UIMap[_info.UIName]; ui.OnHide(); ui.gameObject.SetActive(false); if (UIHideDic.ContainsKey(_info.UIName)) { UIHideDic.Remove(_info.UIName); } UIHideDic.Add(_info.UIName, _info); }
private void OnLoadUIPrefabCallBack(ref UIOpenInfo _info) { string uiName = _info.UIName; if (UILoadList.IndexOf(uiName) > 0) { UILoadList.Remove(uiName); } Transform parentTrans = null; if (_info.UIParentTrans == null) { parentTrans = _uiNormalPath; } else { parentTrans = _info.UIParentTrans; } try { if (parentTrans.Find(_info.UIName) == null) { _info.UIObj = (GameObject)MonoBehaviour.Instantiate(_info.UIObj); //_info.UIObj.transform.parent = parentTrans; _info.UIObj.transform.SetParent(parentTrans, false); _info.UIObj.name = _info.UIName; } } catch (Exception e) { Debug.LogError("UI加载错误::" + e.ToString()); } ShowUI(ref _info); }
/// <summary> /// 退出panelDep 计算 /// </summary> public static void CloseChildPanelDep(UIOpenInfo uiData) { OrderChildPanel(uiData, curMaxUIDepth, true); resourceAllPannelDepth(); }
public void OpenUI(string _path, Transform _parentTrans = null, params object[] _parms) { UIOpenInfo tmpUiInfo = new UIOpenInfo(_path, _parentTrans, _parms); _UIManager.OpenUI(ref tmpUiInfo); }