This commit is contained in:
2025-05-23 00:26:58 +08:00
parent 2ca8eac832
commit 4b7a6b1dc8
22 changed files with 194 additions and 22 deletions

View File

@@ -9,6 +9,7 @@ namespace NBF
public static void BindAll()
{
UIObjectFactory.SetPackageItemExtension(CommonMenu.URL, typeof(CommonMenu));
UIObjectFactory.SetPackageItemExtension(ListTitleItem.URL, typeof(ListTitleItem));
}
}
}

View File

@@ -8,6 +8,7 @@ namespace NBF
{
public static void BindAll()
{
UIObjectFactory.SetPackageItemExtension(ShopGearItem.URL, typeof(ShopGearItem));
}
}
}

View File

@@ -0,0 +1,25 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class ListTitleItem
{
public const string URL = "ui://6hgkvlauoomea";
public GImage back;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
back = (GImage)GetChild("back");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8042079334b43394ca275c4a2189dbfb

View File

@@ -0,0 +1,15 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class ListTitleItem : GComponent
{
private void OnInited()
{
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: d1c42293e0f4ae546ba4419aa2ed199c

View File

@@ -1,21 +1,51 @@
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using System.Collections.Generic;
using FairyGUI;
using UnityEngine;
using NBC;
using UIPanel = NBC.UIPanel;
namespace NBF
{
public class ListDataBase
{
public string title;
}
public class ShopGearData : ListDataBase
{
}
public partial class FishingShopPanel : UIPanel
{
public override string UIPackName => "Shop";
public override string UIResName => "FishingShopPanel";
private List<ListDataBase> _data = new List<ListDataBase>();
protected override void OnInit()
{
base.OnInit();
this.AutoAddClick(OnClick);
Menu.OnClose += Hide;
for (int i = 0; i < 10; i++)
{
var data = new ListDataBase();
data.title = "Title" + i;
_data.Add(data);
for (int j = 0; j < 30; j++)
{
var item = new ShopGearData();
item.title = $"Item {i}-" + j;
_data.Add(item);
}
}
// List.SetVirtual();
List.itemProvider = GetListItemResource;
List.itemRenderer = OnRenderItem;
List.numItems = _data.Count;
}
protected override void OnShow()
@@ -23,6 +53,38 @@ namespace NBF
base.OnShow();
}
void OnRenderItem(int index, GObject obj)
{
if (obj is ListTitleItem titleItem)
{
titleItem.width = List.width - 60;
titleItem.height = 47;
}
// else
// {
// obj.width = 224;
// obj.height = 320;
// }
}
//根据索引的不同返回不同的资源URL
string GetListItemResource(int index)
{
var itemData = _data[index];
if (itemData is ShopGearData shopItem)
{
return ShopGearItem.URL;
}
if (itemData is ListDataBase item)
{
return ListTitleItem.URL;
}
return List.defaultItem;
}
private void OnClick(GComponent btn)
{
// if (btn == BtnClose)

View File

@@ -0,0 +1,27 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class ShopGearItem
{
public const string URL = "ui://146ra2lqoome9";
public GGraph select;
public GGraph over;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
select = (GGraph)GetChild("select");
over = (GGraph)GetChild("over");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f1c9e707edc525b419a4d8469675a653

View File

@@ -0,0 +1,15 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class ShopGearItem : GButton
{
private void OnInited()
{
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 88f8461d076edc549bc841c01f0e42a3