| using System.Collections; | 
| using System.Collections.Generic; | 
| using UnityEngine; | 
| using UnityEngine.UI; | 
|   | 
| /// <summary> | 
| /// 多页签界面,管理子界面 | 
| /// </summary> | 
| public abstract class FunctionsBaseWin : UIBase | 
| { | 
|     // 标签按钮组 | 
|     public GroupButtonEx[] tabButtons; | 
|   | 
|     // 当前打开的子界面 | 
|     protected UIBase currentSubUI; | 
|   | 
|     /// <summary> | 
|     /// 初始化组件 | 
|     /// </summary> | 
|     protected override void InitComponent() | 
|     { | 
|         // 初始化UI组件事件 | 
|         InitButtonEvents(); | 
|     } | 
|     protected override void OnPreOpen() | 
|     { | 
|         // 默认选中第一个标签 | 
|         SelectBottomTab(functionOrder); | 
|   | 
|     } | 
|   | 
|     protected override void OnPreClose() | 
|     { | 
|         CloseCurrentSubUI(); | 
|     } | 
|   | 
|   | 
|   | 
|     /// <summary> | 
|     /// 初始化UI组件事件 | 
|     /// </summary> | 
|     private void InitButtonEvents() | 
|     { | 
|         // 初始化底部按钮 | 
|         for (int i = 0; i < tabButtons.Length; i++) | 
|         { | 
|             int index = i; | 
|             tabButtons[i].AddListener(() => | 
|             { | 
|                 OnTabButtonClicked(index); | 
|             }); | 
|         } | 
|   | 
|     } | 
|   | 
|   | 
|   | 
|     /// <summary> | 
|     /// 选择标签 | 
|     /// </summary> | 
|     protected void SelectBottomTab(int index) | 
|     { | 
|         // 如果点击当前已选中的标签,不做处理 | 
|         if (functionOrder == index && currentSubUI != null) | 
|         { | 
|             return; | 
|         } | 
|   | 
|         // 更新当前选中的标签索引 | 
|         functionOrder = index; | 
|   | 
|         // 关闭当前打开的子界面 | 
|         CloseCurrentSubUI(); | 
|   | 
|         // 根据选中的标签打开对应的界面 | 
|         OpenSubUIByTabIndex(); | 
|     } | 
|   | 
|   | 
|     /// <summary> | 
|     /// 关闭当前打开的子界面 | 
|     /// </summary> | 
|     protected void CloseCurrentSubUI() | 
|     { | 
|         if (currentSubUI != null) | 
|         { | 
|             // 关闭当前界面 | 
|             currentSubUI.CloseWindow(); | 
|             currentSubUI = null; | 
|         } | 
|     } | 
|   | 
|   | 
|   | 
|   | 
|     /// <summary> | 
|     /// 根据标签索引打开对应的子界面 | 
|     /// </summary> | 
|     protected abstract void OpenSubUIByTabIndex(); | 
|   | 
|   | 
|     /// <summary> | 
|     /// 标签按钮点击 | 
|     /// </summary> | 
|     protected virtual void OnTabButtonClicked(int index) | 
|     { | 
|         SelectBottomTab(index); | 
|     } | 
| } |