// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖 using System.Collections.Generic; using FairyGUI; using NBC; using UIPanel = NBC.UIPanel; namespace NBF { public class ShopGearData { public string title; } public partial class FishingShopPanel : UIPanel { public override string UIPackName => "Shop"; public override string UIResName => "FishingShopPanel"; private List _tabList = new List(); protected override void OnInit() { base.OnInit(); this.AutoAddClick(OnClick); Menu.OnClose += Hide; for (int i = 0; i < 10; i++) { var itemData = new TabListData(); itemData.AddTestData(i); _tabList.Add(itemData); } Menu.OnTabChange += ChangeTab; List.OnClickItem += OnClickItem; } protected override void OnShow() { base.OnShow(); Menu.SetTabs(_tabList); } private void ChangeTab(int index) { Log.Info($"Change tab index={index}"); var listData = _tabList[index]; List.SetListData(listData.ListData); } private void OnClickItem(object item) { if(item is not ShopGearItem shopGearItem) return; Log.Info($"click item ={shopGearItem.GearData.title}"); } private void OnClick(GComponent btn) { // if (btn == BtnClose) // { // Hide(); // } } protected override void OnHide() { base.OnHide(); } protected override void OnDestroy() { base.OnDestroy(); } } }