Beispiel #1
0
    /// <summary>
    /// 打开一个界面,同时关闭其他的界面
    /// </summary>
    /// <param name="viewName">需要打开的界面</param>
    /// <param name="hideList">需要关闭的界面列表</param>
    /// <param name="listener">回调函数</param>
    public void ShowView(string viewName, List<string> hideViewList , IShowViewListener listener, bool createAndShow = false )
    {
        //如果缓存中存在对应UI,则显示UI并调用对应的函数
        BaseUI baseUI = null;
        for (int i = 0; i < hideViewList.Count; i++)
        {
            if (mDicView.TryGetValue(viewName, out baseUI) && baseUI != null)
            {
                baseUI.Hide();
            }
        }

        if (mDicView.TryGetValue(viewName, out baseUI))
        {
            if (baseUI != null)
            {
                baseUI.Show();
                if (listener != null)
                {

                    listener.Succeed(baseUI);
                }
            }
            else
            {
                mDicView.Remove(viewName);
            }
            return;
        }

        for (int i = 0; i <mLoadIns.Count ; i++)
        {
            if (mLoadIns[i].viewName.Equals(viewName))
            {
                mLoadIns[i].AddShowViewListener(listener);
                return;
            }
        }
        LoadViewCallBack callBack = new LoadViewCallBack(viewName,LoadViewCallBack.LoadViewType.Show);
        if (createAndShow)
        {
            callBack.loadType = LoadViewCallBack.LoadViewType.Create;
        }
        callBack.AddShowViewListener(listener);
        CreateView(callBack);
    }
Beispiel #2
0
 /// <summary>
 /// 创建一个界面
 /// </summary>
 /// <param name="callBack"></param>
 private void CreateView(LoadViewCallBack callBack)
 {
     if (callBack == null)
     {
         return;
     }
     mLoadIns.Add(callBack);
     ResManager.Instance.LoadAssetAsync(callBack.viewName,typeof(GameObject),callBack,true);
 }
Beispiel #3
0
 /// <summary>
 /// 去除一个当前正在加载的界面
 /// </summary>
 /// <param name="loadViewCallBack"></param>
 public void RemoveLoadIns(LoadViewCallBack loadViewCallBack)
 {
     if (mLoadIns.Contains(loadViewCallBack))
     {
         mLoadIns.Remove(loadViewCallBack);
     }
 }