예제 #1
0
        private void _addAsbInfo(string asbName, string name, string extral, bool isOrdered)
        {
            if (null == OnLoadCallbcak)
            {
                return;
            }
            AsbInfo info = ObjPools.GetAsbInfo();

            info.Set(asbName, name, extral);
            if (isOrdered)
            {
                if (!mQueue.Contains(info))
                {
                    mQueue.Enqueue(info);
                    return;
                }
            }
            else
            {
                if (!mList.Contains(info))
                {
                    mList.Add(info);
                    return;
                }
            }
            //如果已经在list或者队列里则回收
            ObjPools.Recover(info);
            return;
        }
예제 #2
0
 /// <summary>
 /// 从prefab显示UI,慎用,建议使用ShowView
 /// </summary>
 /// <param name="prefab">Prefab.</param>
 /// <param name="luaTable">Lua table.</param>
 /// <param name="asbName">Asb name.</param>
 /// <param name="prefabName">Prefab name.</param>
 public void ShowViewPrefab(GameObject prefab, LuaTable luaTable = null, string asbName = null, string prefabName = null)
 {
     if (null != prefab)
     {
         GameObject uiObj = Instantiate(prefab);
         UIBase     ui    = uiObj.GetComponent <UIBase>();
         if (null != luaTable)
         {
             ui.SetLuaStatusListeners(luaTable);
         }
         _addUIObj(ui);
         if (ui.IsStatic)
         {
             if (mStaticViewInfos.Count == mStaticViews.Count)
             {
                 AsbInfo info = ObjPools.GetAsbInfo();
                 info.Set(asbName, prefabName);
                 mStaticViewInfos.Add(info);
                 mStaticViews.Add(ui);
             }
             else
             {
                 LogFile.Error("GameUIManager error ==> showViewPrefab mStaticViewInfos.Count != mStaticViews.Count");
             }
         }
         //要显示UI先SetActive(true),防止有UIprefab中没有启用,不会进入Start方法
         uiObj.SetActive(true);
         //UI初始化后才Show(播放显示动画)
         ui.OnInitCallbcak = (bool hasInit) =>
         {
             if (ui.IsInStack)
             {
                 if (ui.HideBefor && mStackViews.Count > 0)
                 {
                     UIBase curView = mStackViews.Peek();
                     if (curView.isActiveAndEnabled)
                     {
                         HideView(curView, (bool ret) =>
                         {
                             _pushUI(ui as UIView);
                             ShowViewObj(ui, null);
                         });
                         return;
                     }
                 }
                 //之前的UI隐藏或者本UI被设置为不隐藏之前的UI则不隐藏之前的UI直接push
                 {
                     _pushUI(ui as UIView);
                     ShowViewObj(ui, null);
                 }
             }
             else
             {
                 ShowViewObj(ui, null);
             }
         };
     }
 }