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(); }
public void Close(string uiName, Action callback) { ChildUI childUI = null; if (!childDic.TryGetValue(uiName, out childUI)) { return; } CloseAsync(uiName, callback); }
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); } } }
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); } } }
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); } } }
/// <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); }
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); }
/// <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); }
/// <summary> /// 添加子UI /// </summary> /// <param name="childUIName">子UI名字</param> /// <param name="childUI">子UI实例</param> public void AddChildUI(string childUIName, ChildUI childUI) { childUIContainer.AddChildUI(childUIName, childUI); }