private void AddUIPanel(AutoLayerTag tag, QUIBehaviour ui) { if (!mUILayerMap.ContainsKey(tag)) { mUILayerMap.Add(tag, new List <QUIBehaviour>()); } mUILayerMap[tag].Add(ui); var order = HIDE_INDEX; switch (tag) { case AutoLayerTag.Bottom: mBottomOrder += mNormalPadding; order = mBottomOrder; break; case AutoLayerTag.Top: mTopOrder += mNormalPadding; order = mTopOrder; break; case AutoLayerTag.Hide: break; } ui.LayerSortIndex = order; }
public void SetLayer(int uiLevel, QUIBehaviour ui) { if (ui == null) { return; } ui.UILayerType = uiLevel; switch (uiLevel) { case (int)UILevel.AlwayBottom: AddUIPanel(AutoLayerTag.Bottom, ui); ui.Transform.SetParent(mAlwayBottomLayer); break; case (int)UILevel.AlwayTop: AddUIPanel(AutoLayerTag.Top, ui); ui.Transform.SetParent(mAlwayTopLayer); break; default: AddCommUIPanel(uiLevel, ui); ui.Transform.SetParent(mCommLayer); break; } InitailRectTrans(ui.Transform as RectTransform); }
public void OnUIPanelHide(QUIBehaviour ui) { RemoveUILayer(ui); AddUIPanel(AutoLayerTag.Hide, ui); ui.Transform.SetParent(mHideLayer); InitailRectTrans(ui.Transform as RectTransform); }
public void OnUIPanelShow(QUIBehaviour ui) { if (mUILayerMap.ContainsKey(AutoLayerTag.Hide) && mUILayerMap[AutoLayerTag.Hide].Contains(ui)) { mUILayerMap[AutoLayerTag.Hide].Remove(ui); SetLayer(ui.UILayerType, ui); } }
public void InternalRemoveMenu(QUIBehaviour _handler) { System.Type type = _handler.GetType(); string key = type.ToString(); if (mAllUI.ContainsKey(key)) { mAllUI.Remove(key); } }
private bool RemoveUIPanel(AutoLayerTag tag, QUIBehaviour ui) { if (mUILayerMap.ContainsKey(tag) && mUILayerMap[tag].Contains(ui)) { return(mUILayerMap[tag].Remove(ui)); } else { return(false); } }
public void CloseUI(string behaviourName) { QUIBehaviour behaviour = null; mAllUI.TryGetValue(behaviourName, out behaviour); if (null != behaviour) { (behaviour as IUI).Close(); mAllUI.Remove(behaviourName); } }
/// <summary> /// 创建UIPanel /// </summary> /// <param name="uiBehaviourName"></param> /// <param name="uiLevel"></param> /// <param name="initData"></param> /// <returns></returns> public GameObject CreateUIObj(string uiBehaviourName, int uiLevel, string assetBundleName = null) { IUIBehaviour ui; if (mAllUI.TryGetValue(uiBehaviourName, out ui)) { Log.W("{0}: already exist", uiBehaviourName); // 直接返回,不要再调一次Init(),Init()应该只能调用一次 return(ui.Transform.gameObject); } ui = QUIBehaviour.Load(uiBehaviourName, assetBundleName); mLayerLogic.SetLayer(uiLevel, ui as QUIBehaviour); mUIPanelStack.OnCreatUI(uiLevel, ui, uiBehaviourName); ReSetLayerIndexDirty(); ui.Transform.gameObject.name = uiBehaviourName; return(ui.Transform.gameObject); }
private void AddCommUIPanel(int uiLevel, QUIBehaviour ui) { if (!mUILayerMap.ContainsKey(AutoLayerTag.Comm)) { mUILayerMap.Add(AutoLayerTag.Comm, new List <QUIBehaviour>()); } mUILayerMap[AutoLayerTag.Comm].Add(ui); mCommOrder[uiLevel + diffValue] += mNormalPadding; var order = HIDE_INDEX; if (uiLevel + diffValue < 0 || uiLevel - diffValue >= mCommOrder.Length) { ui.LayerSortIndex = order; return; } order = mCommOrder[uiLevel + diffValue]; ui.LayerSortIndex = order; }
private void RemoveUILayer(QUIBehaviour ui, int uiLevel = -10000) { if (uiLevel == -10000) { uiLevel = ui.UILayerType; } switch (uiLevel) { case (int)UILevel.AlwayBottom: if (RemoveUIPanel(AutoLayerTag.Bottom, ui)) { //mBottomOrder -= mNormalPadding; } break; case (int)UILevel.AlwayTop: if (RemoveUIPanel(AutoLayerTag.Top, ui)) { //mTopOrder -= mNormalPadding; } break; default: if (RemoveUIPanel(AutoLayerTag.Comm, ui)) { Log.I(ui.name); if (uiLevel + diffValue < 0 || uiLevel - diffValue >= mCommOrder.Length) { } else { //mCommOrder[uiLevel + diffValue] -= mNormalPadding; } } break; } }
/// <summary> /// 创建UIPanel /// </summary> /// <param name="uiBehaviourName"></param> /// <param name="uiLevel"></param> /// <param name="initData"></param> /// <returns></returns> public GameObject CreateUIObj(string uiBehaviourName, int uiLevel) { IUIBehaviour ui; if (mAllUI.TryGetValue(uiBehaviourName, out ui)) { Log.W("{0}: already exist", uiBehaviourName); // 直接返回,不要再调一次Init(),Init()应该只能调用一次 return(ui.Transform.gameObject); } ui = QUIBehaviour.Load(uiBehaviourName); switch (uiLevel) { case (int)UILevel.Bg: ui.Transform.SetParent(mBgTrans); break; case (int)UILevel.AnimationUnderPage: ui.Transform.SetParent(mAnimationUnderPageTrans); break; case (int)UILevel.Common: ui.Transform.SetParent(mCommonTrans); break; case (int)UILevel.AnimationOnPage: ui.Transform.SetParent(mAnimationOnPageTrans); break; case (int)UILevel.PopUI: ui.Transform.SetParent(mPopUITrans); break; case (int)UILevel.Const: ui.Transform.SetParent(mConstTrans); break; case (int)UILevel.Toast: ui.Transform.SetParent(mToastTrans); break; case (int)UILevel.Forward: ui.Transform.SetParent(mForwardTrans); break; } #if NONE_LUA_SUPPORT var uiGoRectTrans = ui.Transform as RectTransform; uiGoRectTrans.offsetMin = UnityEngine.Vector2.zero; uiGoRectTrans.offsetMax = UnityEngine.Vector2.zero; uiGoRectTrans.anchoredPosition3D = Vector3.zero; uiGoRectTrans.anchorMin = UnityEngine.Vector2.zero; uiGoRectTrans.anchorMax = UnityEngine.Vector2.one; #endif ui.Transform.LocalScaleIdentity(); ui.Transform.gameObject.name = uiBehaviourName; return(ui.Transform.gameObject); }
private int SortCompare(QUIBehaviour a, QUIBehaviour b) { return(a.LayerSortIndex.CompareTo(b.LayerSortIndex)); }
//TODO隐藏和关闭在重排之前不得进行创建,要约束一下 public void OnUIPanelClose(QUIBehaviour ui) { RemoveUILayer(ui); }