예제 #1
0
        private async void CloseAsync(string uiName, Action callback)
        {
            await WaitAnimationFinished();

            MaskManager.Instance.SetActive(true);

            for (int i = 0; i < showList.Count; i++)
            {
                ChildUI tempChildUI = showList[i];
                if (tempChildUI != null && tempChildUI.UIContext.UIData.UIName == uiName)
                {
                    showList.RemoveAt(i);
                    break;
                }
            }

            ChildUI childUI = null;

            if (childDic.TryGetValue(uiName, out childUI))
            {
                await childUI.DisableAsync();
            }

            MaskManager.Instance.SetActive(false);

            callback?.Invoke();
        }
예제 #2
0
        public void Close(string uiName, Action callback)
        {
            ChildUI childUI = null;

            if (!childDic.TryGetValue(uiName, out childUI))
            {
                return;
            }
            CloseAsync(uiName, callback);
        }
예제 #3
0
 public void Disable()
 {
     for (int i = 0; i < showList.Count; i++)
     {
         ChildUI childUI = showList[i];
         if (childUI != null && !childUI.UIContext.UIData.HasAnimation)
         {
             childUI.DisableAsync().ConfigureAwait(true);
         }
     }
 }
예제 #4
0
 public void BeforeDisable()
 {
     //父UI执行Disable之前,有动画的子UI需要播放退场动画
     for (int i = 0; i < showList.Count; i++)
     {
         ChildUI childUI = showList[i];
         if (childUI != null && childUI.UIContext.UIData.HasAnimation)
         {
             childUI.DisableAsync().ConfigureAwait(true);
         }
     }
 }
예제 #5
0
 public void Enable()
 {
     //父UI执行Enable之前,需要把显示列表的UI执行Enable
     for (int i = 0; i < showList.Count; i++)
     {
         ChildUI childUI = showList[i];
         if (childUI != null)
         {
             childUI.EnableAsync().ConfigureAwait(true);
         }
     }
 }
예제 #6
0
        /// <summary>
        /// 添加子UI
        /// </summary>
        /// <param name="uiName">子UI名字</param>
        /// <param name="childUI">子UI实例</param>
        public void AddChildUI(string uiName, ChildUI childUI)
        {
            if (string.IsNullOrEmpty(uiName) || childUI == null)
            {
                return;
            }

            if (childDic == null)
            {
                childDic = new Dictionary <string, ChildUI>();
            }

            childDic.Add(uiName, childUI);
        }
예제 #7
0
        private async void OpenAsync(string uiName, Action <UI> callback, params object[] args)
        {
            await WaitAnimationFinished();

            MaskManager.Instance.SetActive(true);

            Task loadTask = UIManager.Instance.LoadUIAsync(uiName);
            {
                //容错处理,UI可能不存在
                if (loadTask == null)
                {
                    MaskManager.Instance.SetActive(false);
                }
                await loadTask;
            }

            ChildUI childUI = null;

            if (childDic != null)
            {
                if (!childDic.TryGetValue(uiName, out childUI))
                {
                    MaskManager.Instance.SetActive(false);
                }
                else
                {
                    if (!showList.Contains(childUI))
                    {
                        showList.Add(childUI);
                    }

                    //设置子UI层级
                    childUI.SetCavansOrder(childUI.ParentUI.SortingOrder + 1);

                    if (childUI.UIState == UIStateType.Awake)
                    {
                        await childUI.StartAsync(args);
                    }
                    else if (childUI.UIState == UIStateType.Start || childUI.UIState == UIStateType.Disable)
                    {
                        await childUI.EnableAsync();
                    }
                }
            }

            MaskManager.Instance.SetActive(false);

            callback?.Invoke(childUI);
        }
예제 #8
0
        /// <summary>
        /// 移除子UI,不播放动画
        /// </summary>
        /// <param name="uiName"></param>
        public void Remove(string uiName)
        {
            ChildUI childUI = null;

            for (int i = showList.Count - 1; i >= 0; i--)
            {
                ChildUI showChild = showList[i];
                if (showChild != null && showChild.UIContext.UIData.UIName == uiName)
                {
                    childUI = showChild;
                    showList.RemoveAt(i);
                }
            }

            childDic?.Remove(uiName);
            UIManager.Instance.Remove(uiName);
        }
예제 #9
0
파일: GameUI.cs 프로젝트: lin5/UIFramework
 /// <summary>
 /// 添加子UI
 /// </summary>
 /// <param name="childUIName">子UI名字</param>
 /// <param name="childUI">子UI实例</param>
 public void AddChildUI(string childUIName, ChildUI childUI)
 {
     childUIContainer.AddChildUI(childUIName, childUI);
 }