33 lines
943 B
C#
33 lines
943 B
C#
using Godot;
|
|
using System.Collections.Generic;
|
|
|
|
public partial class ResourceGrid : GridContainer
|
|
{
|
|
[Export]
|
|
public PackedScene ItemPanelScene;
|
|
|
|
public override void _Ready()
|
|
{
|
|
// 获取基础资源分类的所有物品
|
|
var items = ResourceCategoryManager.Instance.GetItemsByCategory("基础资源");
|
|
|
|
foreach (var item in items.Values)
|
|
{
|
|
var panel = (Panel)ItemPanelScene.Instantiate();
|
|
|
|
// 设置图标为白色底色
|
|
var icon = panel.GetNode<TextureRect>("HBoxContainer/Icon");
|
|
icon.Texture = null;
|
|
icon.Modulate = new Color(1, 1, 1, 1); // 白色
|
|
|
|
// 设置名称
|
|
var nameLabel = panel.GetNode<Label>("HBoxContainer/VBoxContainer/TopRow/NameLabel");
|
|
nameLabel.Text = item.Name;
|
|
|
|
// 其余内容可根据需要设置
|
|
// ...
|
|
|
|
AddChild(panel);
|
|
}
|
|
}
|
|
} |