예제 #1
0
        private void ManagerMask()
        {
            Debug.Log("ManagerMask");
            LoadUIData maskData = null;

            for (int i = 0; i < m_AllUIStack.Count; i++)
            {
                LoadUIData data = m_AllUIStack[i];
                if (data.uiBase != null && !data.isLoading && data.info.maskType != UIMaskType.None)
                {
                    if (maskData == null)
                    {
                        maskData = data;
                    }
                    else
                    {
                        if (maskData.layer <= data.layer)
                        {
                            maskData = data;
                        }
                    }
                }
            }
            if (maskData != null)
            {
                StartCoroutine(ManagerMaskShow(maskData));
            }
            else
            {
                HideMask();
            }
        }
예제 #2
0
 /// <summary>
 /// 当ui显示的时候(包括出生或者重新显示)需要处理的事件
 /// 比如是否要添加Mask,ComFull类型的ui是全屏,需要隐藏在此ui之前的所有全屏ui,ComPopup 是独立弹窗不受影响
 /// </summary>
 /// <param name="ui"></param>
 private void ManagerUIShowEvent(LoadUIData data)
 {
     if (data.info.uiType == UIType.ComFull)
     {
         bool startHide = false;
         if (m_UIStack.Count >= 2)
         {
             for (int i = m_UIStack.Count - 1; i >= 0; i--)
             {
                 var ui = m_UIStack[i];
                 if (ui.info.uiType != UIType.ComPopup)
                 {
                     if (ui.info.Equals(data.info))
                     {
                         startHide = true;
                         continue;
                     }
                     if (startHide)
                     {
                         ui.uiBase.HideUI();
                     }
                 }
             }
         }
     }
 }
예제 #3
0
 /// <summary>
 /// 在关闭某个ui的时候,需要停止这个ui正在进行的协程
 /// </summary>
 /// <param name="data"></param>
 public void CallAfterCloseUI(LoadUIData data)
 {
     if (data.info.iterator != null)
     {
         StopCoroutine(data.info.iterator);
     }
 }
예제 #4
0
        private IEnumerator CoLoadUI(UIInfo info, Action <UIBase> showEvent = null, params object[] userDatas)
        {
            LoadUIData data = PrePushToAllStack(info, userDatas);
            //先从对象池里面加载物体,没有找到对应的物体就加载一个,加载出来要放进对象池中保存起来
            GameObject obj = PoolManager.instance.GetObject <GameObject>(info.loadPath, info.loadPath.GetAssetName(), AssetType.Prefab);

            if (obj == null)
            {
                //动态加载
                var handle = Addressables.InstantiateAsync(info.loadPath);
                yield return(handle);

                if (handle.Result != null)
                {
                    obj = handle.Result;
                    //加载完了放入对象池
                    PoolManager.instance.AddItemToPool(info.loadPath, info.loadPath.GetAssetName(), obj, AssetType.Prefab, true);
                }
            }
            data.isLoading = false;

            if (obj != null)
            {
                obj.transform.SetParent(m_root);
                UIBase ui = obj.GetOrAddComponent <UIBase>();
                if (!ui.IsInit)
                {
                    ui.InitUI(info);
                }
                ui.CloseSelfEvent += OnClickCloseEvent;
                data.uiBase        = ui;
                PushUIDataToAllStack(data);
                PushUIToSelfStack(data);
                if (data.info.maskType != UIMaskType.None)
                {
                    ManagerMask();
                }

                IEnumerator iterator = ui.ShowUI(info.userDatas);
                info.iterator = iterator;
                yield return(iterator);

                showEvent?.TryInvoke(ui);

                LoadUIComplete(data);

                IEnumerator iterator2 = ui.LoadCompleteUI(info.userDatas);
                info.iterator = iterator2;
                yield return(iterator2);

                info.iterator = null;
            }
            else
            {
                Debug.LogError("Load " + data.info.loadPath + " fail!!! ");
            }
        }
예제 #5
0
        public void PushUIToStack(LoadUIData data)
        {
            var ui = data.uiBase;

            ui.UICanvas.sortingOrder = GetSortOrderByIndex(GetCurLayerTotalIndex(data.layer), data.layer);
            ui.CloseSelfEvent       += ClickCloseUI;
            data.uiBase.Layer        = data.layer;
            m_UIStack.Add(data);
        }
예제 #6
0
 private bool IsExitUIBase(LoadUIData data)
 {
     if (data.uiBase == null)
     {
         Debug.Log(data.info.loadPath.GetAssetName() + " uibase is null !!!!");
         return(false);
     }
     return(true);
 }
예제 #7
0
 /// <summary>
 /// 在加载之前Push过加载数据,数据只包含加载路径和加载状态
 /// 加载成功之后,找到对应的加载数据替换成全新的加载数据。
 /// </summary>
 /// <param name="data"></param>
 private void PushUIDataToAllStack(LoadUIData data)
 {
     for (int i = m_AllUIStack.Count - 1; i >= 0; i--)
     {
         if (m_AllUIStack[i].info.Equals(data.info))
         {
             m_AllUIStack[i] = data;
         }
     }
 }
예제 #8
0
        /// <summary>
        /// 先把加载信息放入全局的堆栈里面
        /// </summary>
        private LoadUIData PrePushToAllStack(UIConfig config, params object[] userDatas)
        {
            LoadUIData data = new LoadUIData();

            data.uiConfig  = config;
            data.isLoading = true;
            data.isClosed  = false;
            data.userDatas = userDatas;
            m_loadDatas.Add(data);
            return(data);
        }
예제 #9
0
 public void CloseAllUI()
 {
     for (int i = 0; i < m_UIStack.Count; i++)
     {
         LoadUIData data = m_UIStack[i];
         if (data.uiBase != null)
         {
             data.uiBase.DeSpawnUI();
         }
     }
     m_UIStack.Clear();
 }
예제 #10
0
        /// <summary>
        /// 先把加载信息放入全局的堆栈里面
        /// </summary>
        private LoadUIData PrePushToAllStack(UIInfo info, params object[] userDatas)
        {
            LoadUIData data = new LoadUIData();

            data.info          = info;
            data.isLoading     = true;
            data.info.isClosed = false;
            data.layer         = GetLayer(data.info.uiType);
            info.userDatas     = userDatas;
            m_AllUIStack.Add(data);
            return(data);
        }
예제 #11
0
 private void RemoveUIByLayerBurCurUI(LoadUIData curData)
 {
     for (int i = m_AllUIStack.Count - 1; i >= 0; i--)
     {
         var data = m_AllUIStack[i];
         if (IsExitUIBase(data) && !data.Equals(curData) && data.uiBase.Layer == curData.layer)
         {
             data.uiBase.DeSpawnUI();
             m_AllUIStack.RemoveAt(i);
         }
     }
     ManagerMask();
 }
예제 #12
0
 /// <summary>
 ///当某个ui关闭的时候,从m_AllUIStack中移除对应UI
 /// </summary>
 /// <param name="info"></param>
 private void RemoveCurUIFromAllUIStack(UIInfo info)
 {
     for (int i = m_AllUIStack.Count - 1; i >= 0; i--)
     {
         if (m_AllUIStack[i].info.Equals(info))
         {
             LoadUIData loadData = m_AllUIStack[i];
             m_AllUIStack.RemoveAt(i);
             CallAfterCloseUI(loadData);
             break;
         }
     }
 }
예제 #13
0
        private void LoadUIComplete(LoadUIData data)
        {
            var type = data.info.uiType;

            if (type == UIType.ComFull || type == UIType.ComPopup)
            {
                m_commonLoad.LoadComplete(data);
            }
            else
            {
                m_popupLoad.LoadComplete(data);
            }
        }
예제 #14
0
        private void PushUIToSelfStack(LoadUIData data)
        {
            var type = data.info.uiType;

            if (type == UIType.ComFull || type == UIType.ComPopup)
            {
                m_commonLoad.PushUIToStack(data);
            }
            else
            {
                m_popupLoad.PushUIToStack(data);
            }
        }
예제 #15
0
 /// <summary>
 /// 加载ui成功之后,移除加载信息。
 /// </summary>
 /// <param name="data"></param>
 private void RemoveLoadUIData(LoadUIData data)
 {
     if (m_loadDatas.Count <= 0)
     {
         return;
     }
     for (int i = m_loadDatas.Count - 1; i >= 0; i--)
     {
         if (m_loadDatas[i].Equals(data))
         {
             m_loadDatas.RemoveAt(i);
             break;
         }
     }
 }
예제 #16
0
        IEnumerator ManagerMaskShow(LoadUIData loadInfo)
        {
            if (!m_mask)
            {
                yield return(LoadMask());

                if (!m_mask)
                {
                    yield break;
                }
            }

            m_mask.CloseSelfEvent -= MaskClickEvent;
            switch (loadInfo.info.maskType)
            {
            case UIMaskType.OnlyMask:
                m_mask.clickCloseUI = UIPath.None;
                m_mask.SetAlpha();;
                break;

            case UIMaskType.MaskClickClose:
                m_mask.clickCloseUI    = loadInfo.info;
                m_mask.CloseSelfEvent += MaskClickEvent;
                m_mask.SetAlpha();
                break;

            case UIMaskType.TransparentMask:
                m_mask.clickCloseUI = UIPath.None;
                m_mask.SetTransparent();
                break;

            case UIMaskType.TransparentClickMask:
                m_mask.clickCloseUI    = loadInfo.info;
                m_mask.CloseSelfEvent += MaskClickEvent;
                m_mask.SetTransparent();
                break;
            }
            m_mask.UICanvas.sortingOrder = loadInfo.uiBase.UICanvas.sortingOrder - 1;
            m_mask.ResumeUI();
        }
예제 #17
0
 public void LoadComplete(LoadUIData data)
 {
     PushUISuccessful(data);
 }
예제 #18
0
 /// <summary>
 /// Push UI成功之后的事件
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="info"></param>
 /// <param name="loader"></param>
 /// <param name="showEvent"></param>
 /// <param name="userData"></param>
 protected virtual void PushUISuccessful(LoadUIData data)
 {
 }
예제 #19
0
 /// <summary>
 /// 成功加载了UI的事件
 /// loader为空就是从对象池中取出来的
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="data"></param>
 /// <param name="loader"></param>
 /// <param name="showEvent"></param>
 protected override void PushUISuccessful(LoadUIData data)
 {
     ManagerUIShowEvent(data);
 }