Files
Fishing2/Assets/Scripts/UI/Shops/FishingShopPanel.cs
2025-10-13 23:10:47 +08:00

85 lines
2.1 KiB
C#

// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using System.Collections.Generic;
using FairyGUI;
using NBC;
using NUnit.Framework;
using UnityEngine;
using UIPanel = NBC.UIPanel;
namespace NBF
{
public class ShopGearData
{
public string title;
}
public partial class FishingShopPanel : UIPanel
{
protected override void OnInit()
{
base.OnInit();
this.AutoAddClick(OnClick);
IsShowCursor = true;
List<TabItemData> tabItemList = new List<TabItemData>();
for (int i = 0; i < 10; i++)
{
TabItemData tabItem = new TabItemData();
tabItem.Key = $"Tab_{i}";
for (int j = 0; j < 5; j++)
{
TabItemData tabSubItem = new TabItemData();
tabSubItem.Key = $"SubTab_{j}";
var count = Random.Range(2, 5);
for (int k = 0; k < count; k++)
{
var item = new ShopGearData
{
title = $"Item:{i}-{j}-{k}"
};
tabSubItem.Items.Add(item);
}
tabItem.Children.Add(tabSubItem);
}
tabItemList.Add(tabItem);
}
ItemList.SetPanel(this);
ItemList.SetData(tabItemList, true, true);
}
protected override void OnShow()
{
base.OnShow();
UseBottomMenu();
}
private void UseBottomMenu()
{
BottomMenu.Use(this);
}
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 OnDestroy()
{
base.OnDestroy();
}
}
}