| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | using System; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | // 一级界面带预制体,底部功能按钮样式 |
| | | public class OneLevelWin : FunctionsBaseWin |
| | |
| | | [NonSerialized] GroupButtonEx tabBtn; |
| | | public FuncBtnData[] funcBtnDatas; |
| | | [NonSerialized] Button closeBtn; |
| | | |
| | | bool isComponentReady = false; |
| | | |
| | | protected override void InitComponent() |
| | | { |
| | | InitComponentAsync().Forget(); |
| | | } |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | if (!isComponentReady) |
| | | { |
| | | WaitReadyThenOpen().Forget(); |
| | | return; |
| | | } |
| | | base.OnPreOpen(); |
| | | } |
| | | |
| | | private async UniTaskVoid WaitReadyThenOpen() |
| | | { |
| | | await UniTask.WaitUntil(() => isComponentReady || this == null); |
| | | if (this == null) return; |
| | | base.OnPreOpen(); |
| | | } |
| | | |
| | | private async UniTask InitComponentAsync() |
| | | { |
| | | // 创建 |
| | | var instance = UIUtility.CreateWidget("OneLevelWin", "BottomTabs"); |
| | | var instance = await UIUtility.CreateWidget("OneLevelWin", "BottomTabs"); |
| | | if (this == null) |
| | | { |
| | | if (instance != null) DestroyImmediate(instance); |
| | | return; |
| | | } |
| | | instance.transform.SetParent(_rectTransform, false); |
| | | closeBtn = _rectTransform.GetComponent<Button>("BottomTabs/bg/backbtn"); |
| | | tabBtn = _rectTransform.GetComponent<GroupButtonEx>("BottomTabs/bg/btns/funcbtn"); |
| | |
| | | tabButtons[i].SetActive(true); |
| | | } |
| | | base.InitComponent(); |
| | | |
| | | closeBtn.AddListener(CloseWindow); |
| | | |
| | | isComponentReady = true; |
| | | } |
| | | |
| | | protected override void OpenSubUIByTabIndex() |