Ejemplo n.º 1
0
        /// <summary>
        /// 初始化UI数据
        /// 调用Lua初始化;
        /// </summary>
        /// <param name="uiName"></param>
        /// <param name="go"></param>
        private void InitUI(string uiName, GameObject go, object[] args)
        {
            go.transform.SetParent(UIRoot);
            go.transform.ResetTransform();
            RectTransform rt = go.transform.GetComponent <RectTransform>();

            rt.anchorMin = Vector2.zero;
            rt.anchorMax = Vector2.one;
            rt.pivot     = Vector2.one * 0.5f;
            rt.offsetMin = Vector2.zero;
            rt.offsetMax = Vector2.zero;

            go.SetActive(true);
            var canvas = go.GetComponent <Canvas>();

            if (canvas != null)
            {
                orderIndex            += orderInterval;
                canvas.overrideSorting = true;
                canvas.sortingLayerID  = SortingLayer.NameToID("Default");
                canvas.sortingOrder    = orderIndex;
            }
            string luaViewName = UIViewUtils.GetLuaViewName(uiName);

            PanelBridge.SetPanelData(go.GetInstanceID(), uiName, args);
            PanelBridge panelBridge = go.AddComponent <PanelBridge>();

            mPanelStack.Push(panelBridge);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 关闭某个固定页面,并且一同关闭在它后面的所有UI界面;
        /// </summary>
        /// <param name="uiName"></param>
        public void CloseWindowByName(string uiName)
        {
            if (updating)
            {
                mToRemove.Add(uiName);
                return;
            }
            bool flag = false;

            foreach (var item in mPanelStack)
            {
                if (item.UIName.Equals(uiName))
                {
                    flag = true;
                    break;
                }
            }
            if (flag)
            {
                while (mPanelStack.Count > 0)
                {
                    PanelBridge panelBridge = mPanelStack.Pop();
                    if (panelBridge.UIName.Equals(uiName))
                    {
                        GameObject.Destroy(panelBridge.gameObject);
                        break;
                    }
                    else
                    {
                        GameObject.Destroy(panelBridge.gameObject);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 关闭最后一个页面;
 /// </summary>
 public void CloseWindow()
 {
     if (updating)
     {
         mToRemove.Add(null);
         return;
     }
     if (mPanelStack.Count > 0)
     {
         PanelBridge data = mPanelStack.Pop();
         GameObject.Destroy(data.gameObject);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 关闭所有UI界面;
 /// </summary>
 public void CloseAllWindow()
 {
     orderIndex = 1;
     if (updating)
     {
         isCloseAll = true;
         return;
     }
     while (mPanelStack.Count > 0)
     {
         PanelBridge panelBridge = mPanelStack.Pop();
         GameObject.Destroy(panelBridge.gameObject);
     }
     isCloseAll = false;
 }