Files
ichni_Official/Assets/Scripts/UI/Base/TextButton.cs

34 lines
820 B
C#
Raw Normal View History

2025-08-11 14:04:06 -04:00
using UnityEngine;
using UnityEngine.UI;
namespace Ichni.UI
{
public class TextButton : SettingsUIElementBase
{
public Button button;
2026-07-25 13:27:53 -04:00
private bool _isClickListenerRegistered;
/// <summary>
/// 初始化按钮逻辑。标题、说明及按钮文字均由 Prefab 上的 LocalizedTMPText 配置,
/// 不再把字符串当作 I2 的 Term 传入。
/// </summary>
public void SetUp()
2025-08-11 14:04:06 -04:00
{
2026-07-25 13:27:53 -04:00
base.SetUp();
if (_isClickListenerRegistered)
2026-07-24 03:43:11 -04:00
{
2026-07-25 13:27:53 -04:00
return;
2026-07-24 03:43:11 -04:00
}
2025-08-11 14:04:06 -04:00
2026-07-25 13:27:53 -04:00
button.onClick.AddListener(InvokeUpdateValueAction);
_isClickListenerRegistered = true;
}
private void InvokeUpdateValueAction()
{
updateValueAction?.Invoke();
2025-08-11 14:04:06 -04:00
}
}
2026-07-25 13:27:53 -04:00
}