修改 icon bar UI

This commit is contained in:
xianyi
2025-08-13 10:04:07 +08:00
parent a6244708e9
commit ba4cd2d579
6 changed files with 682 additions and 538 deletions

View File

@@ -19,6 +19,10 @@ namespace TcgEngine.UI
public Image[] icons;
public Sprite sprite_full;
public Sprite sprite_empty;
[Header("Value Display")]
public Text value_text; // 显示当前法力值数字的文本组件
public string value_format = "{0}"; // 文本格式,{0}会被替换为当前值
void Awake()
{
@@ -46,6 +50,24 @@ namespace TcgEngine.UI
icon.sprite = (index < value) ? sprite_full : sprite_empty;
index++;
}
// 更新法力值数字文本
UpdateValueText();
}
private void UpdateValueText()
{
if (value_text != null)
{
value_text.text = string.Format(value_format, value);
}
}
// 手动设置值并更新文本
public void SetValue(int new_value)
{
value = new_value;
UpdateValueText();
}
public void SetMat(Material mat)