private string LayerToString(UILayerType layer) { string str = ""; switch (layer) { case UILayerType.Base: str += "[B]"; break; case UILayerType.Tip: str += "[T]"; break; case UILayerType.Warning: str += "[W]"; break; case UILayerType.Pop: str += "[P]"; break; case UILayerType.Story: str += "[S]"; break; default: break; } return(str); }
public static string LayerToString(UILayerType layer, bool showint = true) { string str = ""; if (showint) { str += (int)layer + "|"; } switch (layer) { case UILayerType.Base: str += "[B]"; break; case UILayerType.Tip: str += "[T]"; break; case UILayerType.Warning: str += "[W]"; break; default: break; } return(str); }
public UIPanelData(string module, string name, UILayerType layerType, bool canRepeat = false) { this.m_Name = name; this.m_ResourceName = Config.UIBaseDir + "/" + module + "/" + name; this.layerType = layerType; this.canRepeat = canRepeat; UILayerLevel level = UILayerLevel.Level0; switch (layerType) { case UILayerType.NormalLayer: level = UILayerLevel.Level0; break; case UILayerType.OverLayer: level = UILayerLevel.Level0; break; case UILayerType.TopLayer: level = UILayerLevel.Level1; break; default: level = UILayerLevel.Level0; break; } this.layerLevel = level; }
/// <summary> 添加面板 </summary> public GameObject addChild(UIPanel uiPanel, UILayerType layerType = UILayerType.MIDDLE) { if (uiPanel == null) { return(null); } bool beforInOnelyMe = uiPanel.transform.parent == UILayer_oneyMe; Transform UILayer = null; if (layerType == UILayerType.TOP) { UILayer = UILayer_top; } else if (layerType == UILayerType.TOPPER) { UILayer = UILayer_topper; } else if (layerType == UILayerType.BOTTOM) { UILayer = UILayer_botttom; } else if (layerType == UILayerType.MIDDLE) { UILayer = UILayer_middle; } else if (layerType == UILayerType.NOTHING) { UILayer = UILayer_nothing; } else if (layerType == UILayerType.OVERNERING) { UILayer = UILayer_oneyMe; UILayer_sundry.gameObject.SetActive(false); UILayer_botttom.gameObject.SetActive(false); UILayer_middle.gameObject.SetActive(false); } else if (layerType == UILayerType.SUNDRY) { UILayer = UILayer_sundry; } uiPanel.transform.SetParent(UILayer); uiPanel.gameObject.SetActive(true); uiPanel.transform.SetAsLastSibling(); if (beforInOnelyMe && UILayer_oneyMe.childCount == 0) { UILayer_sundry.gameObject.SetActive(true); UILayer_botttom.gameObject.SetActive(true); UILayer_middle.gameObject.SetActive(true); } if (uiPanel.GetComponent <RectTransform>() != null) { uiPanel.GetComponent <RectTransform>().localScale = new Vector3(1.0f, 1.0f, 1.0f); } uiPanel.dispatchEvent(new DataEvent(DataEvent.ADD_TO_UI)); return(uiPanel.gameObject); }
public GameObject addChildAt(UIPanel uiPanel, int index, UILayerType layerType = UILayerType.MIDDLE) { addChild(uiPanel, layerType); if (index < 0) { index = 0; } uiPanel.transform.SetSiblingIndex(index); return(uiPanel.gameObject); }
public bool CanClose(IUILayer layer) { if (layer == null) { return(false); } UILayerType layerType = layer.LayerType; int maxDepth = GetCurrentLayerMaxDepth(layerType); return(layer.Depth >= maxDepth); }
public bool ChangeLayerMaxDepth(UILayerType layerType, int depth) { int minDepth = GetLayerDepthMin(layerType); int maxDepth = GetLayerDepthMax(layerType); if (depth < minDepth || depth > maxDepth) { return(false); } m_CurrentLayerMaxDepths[(int)layerType] = depth; return(true); }
// 设置层级 public void ShowLayer(IUILayer layer) { if (layer == null) { return; } UILayerType layerType = layer.LayerType; int maxDepth = GetCurrentLayerMaxDepth(layerType) + 1; layer.Depth = maxDepth; ChangeCurrentLayerMaxDepth(layerType, maxDepth); }
//得到指定层的指定UI UIPanelLayerData GetPanelLayer(UILayerType layer, string name) { List <UIPanelLayerData> panelLayerList = m_PanelLayerMap[layer]; for (int i = panelLayerList.Count - 1; i >= 0; i--) { if (panelLayerList[i].name == name) { return(panelLayerList[i]); } } return(null); }
public UILayer GetUILayer(UILayerType type) { switch (type) { case UILayerType.Content: return(UIController.Instance.Content); case UILayerType.Popup: return(UIController.Instance.Popup); } return(null); }
public UIType(UnityEngine.Color maskColor) { this.layerIndex = 0; this.form = UIFormType.Fixed; this.hideAlaph = 0; this.layer = UILayerType.Base; this.enterAnim = null; this.quitAnim = null; this.closeRule = CloseRule.DestroyNoraml; this.hideRule = HideRule.HideGameObject; this.cover = UIMask.None; this.maskColor = maskColor; }
public void RegisterPanel(string module, string name, UILayerType layerType, bool canRepeat) { UIPanelData panelData = new UIPanelData(module, name, layerType, canRepeat); if (!m_PanelMap.ContainsKey(name)) { m_PanelMap.Add(name, panelData); } else { m_PanelMap[name] = panelData; } App.ObjectPoolManager.RegisteObject(panelData.resourceName, panelData.resourceName, 0, 30, -1); }
static int LoadUICallBack(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 9 && TypeChecker.CheckTypes(L, 1, typeof(UIManager), typeof(AssetLoader), typeof(WindowLayer), typeof(UnityEngine.Object), typeof(UIExtendType), typeof(UIOpenType), typeof(bool), typeof(bool), typeof(int))) { UIManager obj = (UIManager)ToLua.ToObject(L, 1); AssetLoader arg0 = (AssetLoader)ToLua.ToObject(L, 2); WindowLayer arg1 = (WindowLayer)ToLua.ToObject(L, 3); UnityEngine.Object arg2 = (UnityEngine.Object)ToLua.ToObject(L, 4); UIExtendType arg3 = (UIExtendType)ToLua.ToObject(L, 5); UIOpenType arg4 = (UIOpenType)ToLua.ToObject(L, 6); bool arg5 = LuaDLL.lua_toboolean(L, 7); bool arg6 = LuaDLL.lua_toboolean(L, 8); int arg7 = (int)LuaDLL.lua_tonumber(L, 9); UnityEngine.GameObject o = obj.LoadUICallBack(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); ToLua.Push(L, o); return(1); } else if (count == 12 && TypeChecker.CheckTypes(L, 1, typeof(UIManager), typeof(UnityEngine.UI.CanvasScaler.ScreenMatchMode), typeof(WindowLayer), typeof(float), typeof(AssetLoader), typeof(UnityEngine.Object), typeof(UIExtendType), typeof(UIOpenType), typeof(UILayerType), typeof(bool), typeof(bool), typeof(int))) { UIManager obj = (UIManager)ToLua.ToObject(L, 1); UnityEngine.UI.CanvasScaler.ScreenMatchMode arg0 = (UnityEngine.UI.CanvasScaler.ScreenMatchMode)ToLua.ToObject(L, 2); WindowLayer arg1 = (WindowLayer)ToLua.ToObject(L, 3); float arg2 = (float)LuaDLL.lua_tonumber(L, 4); AssetLoader arg3 = (AssetLoader)ToLua.ToObject(L, 5); UnityEngine.Object arg4 = (UnityEngine.Object)ToLua.ToObject(L, 6); UIExtendType arg5 = (UIExtendType)ToLua.ToObject(L, 7); UIOpenType arg6 = (UIOpenType)ToLua.ToObject(L, 8); UILayerType arg7 = (UILayerType)ToLua.ToObject(L, 9); bool arg8 = LuaDLL.lua_toboolean(L, 10); bool arg9 = LuaDLL.lua_toboolean(L, 11); int arg10 = (int)LuaDLL.lua_tonumber(L, 12); UnityEngine.GameObject o = obj.LoadUICallBack(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); ToLua.Push(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UIManager.LoadUICallBack")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
// 修改层级关系 public void ChangeCurrentLayerMaxDepth(UILayerType layerType, int depth) { int layer = (int)layerType; if (m_CurrentLayerMaxDepths == null || layer < 0 || layer >= (int)UILayerType.UILayer_NUM) { return; } int minLayer = GetLayerDepthMin(layerType); int maxLayer = GetLayerDepthMax(layerType); if (depth >= minLayer && depth <= maxLayer) { m_CurrentLayerMaxDepths[layer] = depth; } }
// 当前最大层级关系 private int GetCurrentLayerMaxDepth(UILayerType layerType) { int layer = (int)layerType; if (m_CurrentLayerMaxDepths == null || layer < 0 || layer >= (int)UILayerType.UILayer_NUM) { return(GetLayerDepthMin(layerType)); } int maxDepth = m_CurrentLayerMaxDepths[layer]; if (maxDepth == int.MinValue) { maxDepth = GetLayerDepthMin(layerType); } return(maxDepth); }
// 层级Depth最大值 public static int GetLayerDepthMax(UILayerType layerType) { switch (layerType) { case UILayerType.UILayer_MainWindow: return(0); case UILayerType.UILayer_NormalWindow: return(100); case UILayerType.UILayer_PopupWindow: return(200); default: return(100); } }
static int AddFullScreenDlg(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); UIManager obj = (UIManager)ToLua.CheckObject(L, 1, typeof(UIManager)); UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckUnityObject(L, 2, typeof(UnityEngine.GameObject)); UILayerType arg1 = (UILayerType)ToLua.CheckObject(L, 3, typeof(UILayerType)); UILayer o = obj.AddFullScreenDlg(arg0, arg1); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/// <summary>移除一个图层所有的面板</summary> /// <param name="layerType">层级类型</param> /// <param name="ignoreChildNames">忽略UI名称列表</param> /// <param name="destroy">是否直接删除</param> public void remAllChild(UILayerType layerType, List <string> ignoreChildNames = null, bool destroy = false) { Transform UILayer = null; if (layerType == UILayerType.TOP) { UILayer = UILayer_top; } else if (layerType == UILayerType.TOPPER) { UILayer = UILayer_topper; } else if (layerType == UILayerType.BOTTOM) { UILayer = UILayer_botttom; } else if (layerType == UILayerType.MIDDLE) { UILayer = UILayer_middle; } else if (layerType == UILayerType.OVERNERING) { UILayer = UILayer_oneyMe; } for (int i = 0; i < UILayer.transform.childCount;) { if (ignoreChildNames == null || ignoreChildNames.Contains(UILayer.transform.GetChild(i).gameObject.name) == false) { GameObject uiGo = removeChild(UILayer.transform.GetChild(i).GetComponent <UIPanel>(), destroy); if (uiGo == null) { UILayer.transform.GetChild(i).SetParent(null); GameObject.Destroy(uiGo); } } else { i++; } } }
/// <summary> 设置UI的可见性 </summary> public void setUIVisible(UILayerType uiLayerType, bool value) { if (uiLayerType == UILayerType.TOP) { UILayer_top.gameObject.SetActive(value); } else if (uiLayerType == UILayerType.TOPPER) { UILayer_topper.gameObject.SetActive(value); } else if (uiLayerType == UILayerType.MIDDLE) { UILayer_middle.gameObject.SetActive(value); } else if (uiLayerType == UILayerType.BOTTOM) { UILayer_botttom.gameObject.SetActive(value); } else if (uiLayerType == UILayerType.SUNDRY) { UILayer_sundry.gameObject.SetActive(value); } }
public static void SetTranform(Transform item, UILayerType layer, int layerIndex, Transform rootTrans, Transform parent, ref Dictionary <int, Transform> childDic) { if (parent == null) { return; } if (childDic == null) { childDic = new Dictionary <int, Transform>(); } var layerID = (int)layer; Transform root = null; if (!childDic.TryGetValue(layerID, out root) || root == null) { string rootName = string.Format("{0}|{1}", layerID, layer); root = parent.transform.Find(rootName); if (root == null) { root = new GameObject(rootName).transform; root.gameObject.layer = 5; if (parent is RectTransform) { var rectParent = root.gameObject.AddComponent <RectTransform>(); rectParent.anchorMin = Vector2.zero; rectParent.anchorMax = Vector2.one; rectParent.offsetMin = Vector3.zero; rectParent.offsetMax = Vector3.zero; root = rectParent; root.SetParent(parent, false); } else { root.SetParent(parent, true); } root.position = rootTrans.TransformPoint(0, 0, layerID * -1000); if (rootName.StartsWith("-1")) { root.SetAsLastSibling(); } else { int i = 0; for (; i < parent.childCount; i++) { var ritem = parent.GetChild(i); if (ritem.name.StartsWith("-1")) { break; } if (string.Compare(rootName, ritem.name) < 0) { break; } } root.SetSiblingIndex(i); } } childDic[layerID] = root; } item.transform.SetParent(root, !(item.GetComponent <Transform>() is RectTransform)); var childCount = root.childCount; int id = 0; for (int i = 0; i < childCount; i++) { var obj = root.GetChild(i); var panel = obj.GetComponent <IUIPanel>(); if (panel == null || obj == item || panel.UType.layerIndex <= layerIndex) { id = i; } else { break; } } item.SetSiblingIndex(id); }
//得到当前层最上面的UILayer数据 UIPanelLayerData GetTopPanel(UILayerType type) { List <UIPanelLayerData> list = m_PanelLayerMap[type]; return((list.Count > 0) ? list[list.Count - 1] : null); }
//得到当前层最上面的UI名字 public string TopPanelName(UILayerType type) { List <UIPanelLayerData> list = m_PanelLayerMap[type]; return((list.Count > 0) ? list[list.Count - 1].name : ""); }
private bool LayerContains(UILayerType layerEnum) { var layer = (int)layerEnum; return((layerProp.intValue & layer) == layer); }
static int CreateConstPanel(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(PanelManager), typeof(string), typeof(bool))) { PanelManager obj = (PanelManager)ToLua.ToObject(L, 1); string arg0 = ToLua.ToString(L, 2); bool arg1 = LuaDLL.lua_toboolean(L, 3); obj.CreateConstPanel(arg0, arg1); return(0); } else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(PanelManager), typeof(string), typeof(bool), typeof(bool))) { PanelManager obj = (PanelManager)ToLua.ToObject(L, 1); string arg0 = ToLua.ToString(L, 2); bool arg1 = LuaDLL.lua_toboolean(L, 3); bool arg2 = LuaDLL.lua_toboolean(L, 4); obj.CreateConstPanel(arg0, arg1, arg2); return(0); } else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(PanelManager), typeof(string), typeof(UIExtendType), typeof(object))) { PanelManager obj = (PanelManager)ToLua.ToObject(L, 1); string arg0 = ToLua.ToString(L, 2); UIExtendType arg1 = (UIExtendType)ToLua.ToObject(L, 3); object arg2 = ToLua.ToVarObject(L, 4); obj.CreateConstPanel(arg0, arg1, arg2); return(0); } else if (count == 5 && TypeChecker.CheckTypes(L, 1, typeof(PanelManager), typeof(string), typeof(UIExtendType), typeof(object), typeof(int))) { PanelManager obj = (PanelManager)ToLua.ToObject(L, 1); string arg0 = ToLua.ToString(L, 2); UIExtendType arg1 = (UIExtendType)ToLua.ToObject(L, 3); object arg2 = ToLua.ToVarObject(L, 4); int arg3 = (int)LuaDLL.lua_tonumber(L, 5); obj.CreateConstPanel(arg0, arg1, arg2, arg3); return(0); } else if (count == 6 && TypeChecker.CheckTypes(L, 1, typeof(PanelManager), typeof(string), typeof(UIExtendType), typeof(LuaInterface.LuaFunction), typeof(object), typeof(bool))) { PanelManager obj = (PanelManager)ToLua.ToObject(L, 1); string arg0 = ToLua.ToString(L, 2); UIExtendType arg1 = (UIExtendType)ToLua.ToObject(L, 3); LuaFunction arg2 = ToLua.ToLuaFunction(L, 4); object arg3 = ToLua.ToVarObject(L, 5); bool arg4 = LuaDLL.lua_toboolean(L, 6); obj.CreateConstPanel(arg0, arg1, arg2, arg3, arg4); return(0); } else if (count == 6 && TypeChecker.CheckTypes(L, 1, typeof(PanelManager), typeof(string), typeof(UIExtendType), typeof(object), typeof(UnityEngine.UI.CanvasScaler.ScreenMatchMode), typeof(float))) { PanelManager obj = (PanelManager)ToLua.ToObject(L, 1); string arg0 = ToLua.ToString(L, 2); UIExtendType arg1 = (UIExtendType)ToLua.ToObject(L, 3); object arg2 = ToLua.ToVarObject(L, 4); UnityEngine.UI.CanvasScaler.ScreenMatchMode arg3 = (UnityEngine.UI.CanvasScaler.ScreenMatchMode)ToLua.ToObject(L, 5); float arg4 = (float)LuaDLL.lua_tonumber(L, 6); obj.CreateConstPanel(arg0, arg1, arg2, arg3, arg4); return(0); } else if (count == 10 && TypeChecker.CheckTypes(L, 1, typeof(PanelManager), typeof(string), typeof(UIExtendType), typeof(System.Action <UnityEngine.GameObject>), typeof(LuaInterface.LuaFunction), typeof(object), typeof(bool), typeof(UILayerType), typeof(bool), typeof(int))) { PanelManager obj = (PanelManager)ToLua.ToObject(L, 1); string arg0 = ToLua.ToString(L, 2); UIExtendType arg1 = (UIExtendType)ToLua.ToObject(L, 3); System.Action <UnityEngine.GameObject> arg2 = null; LuaTypes funcType4 = LuaDLL.lua_type(L, 4); if (funcType4 != LuaTypes.LUA_TFUNCTION) { arg2 = (System.Action <UnityEngine.GameObject>)ToLua.ToObject(L, 4); } else { LuaFunction func = ToLua.ToLuaFunction(L, 4); arg2 = DelegateFactory.CreateDelegate(typeof(System.Action <UnityEngine.GameObject>), func) as System.Action <UnityEngine.GameObject>; } LuaFunction arg3 = ToLua.ToLuaFunction(L, 5); object arg4 = ToLua.ToVarObject(L, 6); bool arg5 = LuaDLL.lua_toboolean(L, 7); UILayerType arg6 = (UILayerType)ToLua.ToObject(L, 8); bool arg7 = LuaDLL.lua_toboolean(L, 9); int arg8 = (int)LuaDLL.lua_tonumber(L, 10); obj.CreateConstPanel(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: PanelManager.CreateConstPanel")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void Show(UILayerType type) { gameObject.SetActive(true); UIController.Instance.GetUILayer(type).Insert(this); }
protected UILayer(UILayerType layerType, ControlBase parent) { LayerType = layerType; Parent = parent; }
public static void SetTranform(Transform item, UILayerType layer, int layerIndex, Transform parent) { if (parent == null) { return; } string rootName = LayerToString(layer); var root = parent.transform.Find(rootName); if (root == null) { root = new GameObject(rootName).transform; if (parent is RectTransform) { var rectParent = root.gameObject.AddComponent <RectTransform>(); rectParent.anchorMin = Vector2.zero; rectParent.anchorMax = Vector2.one; rectParent.offsetMin = Vector3.zero; rectParent.offsetMax = Vector3.zero; root = rectParent; root.SetParent(parent, false); } else { root.SetParent(parent, true); } if (rootName.StartsWith("-1")) { root.SetAsLastSibling(); } else { int i = 0; for (; i < parent.childCount; i++) { var ritem = parent.GetChild(i); if (ritem.name.StartsWith("-1")) { break; } if (string.Compare(rootName, ritem.name) < 0) { break; } } root.SetSiblingIndex(i); } } item.transform.SetParent(root, !(item.GetComponent <Transform>() is RectTransform)); var childCount = root.childCount; int id = 0; for (int i = 0; i < childCount; i++) { var obj = root.GetChild(i); var panel = obj.GetComponent <IUIPanel>(); if (panel == null || obj == item || panel.UType.layerIndex <= layerIndex) { id = i; } else { break; } } item.SetSiblingIndex(id); }
protected UILayer(UILayerType layerType) { LayerType = layerType; }