Exemple #1
0
        /// <summary>
        /// 打开面板
        /// </summary>
        public void Open(string abName, string assetName, object data = null)
        {
            if (string.IsNullOrEmpty(abName) || string.IsNullOrEmpty(assetName))
            {
                return;
            }
            ViewOpenStruct viewOpenStruct = new ViewOpenStruct();

            viewOpenStruct.asset = new ABAsset(abName, assetName);
            viewOpenStruct.data  = data;
            _QueNeedOpen.Enqueue(viewOpenStruct);
        }
Exemple #2
0
 // 打开面板,面板未打开才允许调用该函数
 void OpenView(BaseView baseView, ViewOpenStruct dataStruct)
 {
     if (!IsOpen(baseView))
     {
         if (baseView.uiType.uiViewType != UIViewType.PopUp)
         {
             _ListOpenView.Add(baseView);
         }
         baseView.Open();
     }
     DisplayView(baseView, dataStruct);
 }
Exemple #3
0
        // 显示面板
        void DisplayView(BaseView baseView, ViewOpenStruct dataStruct)
        {
            // 如果面板的展示类型是隐藏其他类型,则隐藏其他所有显示的面板
            if (baseView.uiType.uiViewType == UIViewType.Normal && baseView.uiType.uiViewShowMode == UIViewShowMode.HideOther)
            {
                HideAllView();
            }

            baseView.DataStruct = dataStruct;
            AddViewToShowDic(dataStruct.asset, baseView);

            // 把面板放到列表最后
            if (_ListOpenView.Contains(baseView))
            {
                _ListOpenView.Remove(baseView);
                _ListOpenView.Add(baseView);
            }
            baseView.transform.SetSiblingIndex(baseView.transform.parent.childCount);

            baseView.Display();
        }
Exemple #4
0
        // 根据需加载队列,加载面板
        void LoadView()
        {
            if (_QueNeedOpen.Count > 0)
            {
                ViewOpenStruct viewOpenStruct = _QueNeedOpen.Dequeue();                        // 从需加载队列中读取界面

                // 判断面板是否已经显示出来
                if (IsDisplay(viewOpenStruct.asset))
                {
                    // 由于已经打开所以缓存中一定会有面板实例
                    BaseView tempBaseView = GetBaseViewFromCache(viewOpenStruct.asset);
                    DisplayView(tempBaseView, viewOpenStruct);
                    return;
                }

                // 尝试从缓存中读取面板实例
                BaseView baseView = GetBaseViewFromCache(viewOpenStruct.asset);

                if (baseView != null)
                {
                    baseView.CancelDispose();               // 取消释放
                    SetViewParent(baseView);
                    OpenView(baseView, viewOpenStruct);
                    return;
                }

                PrefabLoader.LoadPrefab(viewOpenStruct.asset, (obj) => {
                    GameObject prefab = obj as GameObject;
                    baseView          = prefab.GetComponent <BaseView>();
                    GameObject go     = null;
                    if (baseView != null)
                    {
                        switch (baseView.uiType.uiViewType)
                        {
                        case UIViewType.Normal:
                            go       = Instantiate(prefab);
                            baseView = go.GetComponent <BaseView>();
                            _DicNormalViews.Add(viewOpenStruct.asset.ToString(), baseView);
                            break;

                        case UIViewType.Fixed:
                            go       = Instantiate(prefab);
                            baseView = go.GetComponent <BaseView>();
                            _DicFixedViews.Add(viewOpenStruct.asset.ToString(), baseView);
                            break;

                        case UIViewType.PopUp:
                            go       = GameObjectPool.Instance.InstantiateGO(prefab);
                            baseView = go.GetComponent <BaseView>();
                            break;

                        default:
                            break;
                        }
                        SetViewParent(baseView);
                        OpenView(baseView, viewOpenStruct);
                    }
                    else
                    {
                        Debug.LogError("预制体:" + prefab.name + "上没有挂载baseview脚本");
                    }
                });
            }
        }// function_end