46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using FairyGUI;
|
|
using NBC;
|
|
|
|
namespace NBF
|
|
{
|
|
public partial class CommonMenu : GLabel
|
|
{
|
|
public event Action OnClose;
|
|
public event Action<int> OnTabChange;
|
|
private void OnInited()
|
|
{
|
|
BtnClose.onClick.Add(OnClickClose);
|
|
List.onClickItem.Add(OnClickItem);
|
|
}
|
|
|
|
public void SetTabs(List<TabListData> tabList,int selectIndex = 0)
|
|
{
|
|
List.RemoveChildrenToPool();
|
|
for (int i = 0; i < tabList.Count; i++)
|
|
{
|
|
var tabData = tabList[i];
|
|
var tabItem = List.AddItemFromPool().asButton;
|
|
tabItem.title = tabData.TabName;
|
|
}
|
|
Log.Info($"Set tab index={List.selectedIndex}");
|
|
List.selectedIndex = selectIndex;
|
|
OnClickItem();
|
|
}
|
|
|
|
|
|
private void OnClickItem()
|
|
{
|
|
OnTabChange?.Invoke(List.selectedIndex);
|
|
}
|
|
|
|
private void OnClickClose()
|
|
{
|
|
OnClose?.Invoke();
|
|
}
|
|
}
|
|
} |