Ejemplo n.º 1
0
 /// <summary>
 /// 关闭界面
 /// </summary>
 /// <typeparam name="T">界面类</typeparam>
 public void CloseUI <T>()
 {
     for (int i = m_Panels.Count - 1; i >= 0; --i)
     {
         BasePanel panel = m_Panels[i];
         if (panel is T)
         {
             InvokeClose(panel);
             GameObject.Destroy(m_Panels[i].gameObject);
             m_Panels.RemoveAt(i);
             m_IsDirty = true;
             break;
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 创建面板;
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        private BasePanel CreatePanel(PanelType type)
        {
            BasePanel panel = null;

            switch (type)
            {
            case PanelType.Login:
                //...
                break;

            case PanelType.Non:
            default:
                break;
            }
            return(panel);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 打开界面,已存在的界面则置顶显示
        /// </summary>
        /// <param name="name">界面名</param>
        /// <param name="userData">用户自定义数据</param>
        public void OpenUI(string name, params object[] userData)
        {
            //检查是否处于场景销毁过程
            SceneManager sceneManager = GameFramework.GetModule <SceneManager>();

            if (sceneManager != null && sceneManager.IsDestroyingScene)
            {
                Debug.LogException(new InvalidOperationException("Scene being destroyed, operation invalid"));
                return;
            }

            //检查界面是否已存在
            for (int i = m_Panels.Count - 1; i >= 0; --i)
            {
                BasePanel _panel = m_Panels[i];
                if (_panel.UIName == name)
                {
                    m_Panels.RemoveAt(i);
                    m_Panels.Add(_panel);
                    m_IsDirty = true;
                    return;
                }
            }

            //创建新界面
            Type type = Type.GetType(name);

            if (type == null)
            {
                //LuaPanel
                type = typeof(LuaPanel);
            }
            else if (type == typeof(LuaPanel))
            {
                Debug.LogException(new NotSupportedException("Not Supported LuaPanel!"));
                return;
            }
            BasePanel panel = (BasePanel)Activator.CreateInstance(type);

            InvokeInit(panel, name);
            GameObject obj = InstantiatePanel(panel);

            m_Panels.Add(panel);
            InvokeAwake(panel, obj, userData);
            m_IsDirty = true;
        }
Ejemplo n.º 4
0
 protected override void LateUpdate(float deltaTime, float unscaledDeltaTime)
 {
     foreach (BasePanel panel in m_UpdateList)
     {
         InvokeLateUpdate(panel, deltaTime, unscaledDeltaTime);
     }
     if (m_IsDirty)
     {
         m_IsDirty = false;
         //排序
         m_UpdateList.Clear();
         m_UpdateList.AddRange(m_Panels);
         for (int i = 0; i < m_UpdateList.Count; ++i)
         {
             m_UpdateList[i].gameObject.transform.SetSiblingIndex(i);
         }
         bool visible = true;
         for (int i = m_UpdateList.Count - 1; i >= 0; --i)
         {
             BasePanel panel = m_UpdateList[i];
             if (panel.Visible != visible)
             {
                 SetVisible(panel, visible);
                 if (visible)
                 {
                     InvokeReveal(panel);
                 }
                 else
                 {
                     InvokeCover(panel);
                 }
             }
             if (panel.isFullScreen)
             {
                 visible = false;
             }
         }
     }
 }
Ejemplo n.º 5
0
 protected void SetVisible(BasePanel panel, bool visible)
 {
     panel.m_Visible = visible;
 }
Ejemplo n.º 6
0
 protected void InvokeAwake(BasePanel panel, GameObject obj, params object[] userData)
 {
     panel.gameObject = obj;
     panel.OnAwake(userData);
 }
Ejemplo n.º 7
0
 protected void InvokeInit(BasePanel panel, string name)
 {
     panel.m_Valid = true;
     panel.UIName  = name;
     panel.OnInit();
 }
Ejemplo n.º 8
0
 public string GetURL(BasePanel panel)
 {
     return(panel.url);
 }