阶段性完成
This commit is contained in:
@@ -1,7 +1,3 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using I2.Loc;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -10,25 +6,28 @@ namespace Ichni.UI
|
||||
public class TextButton : SettingsUIElementBase
|
||||
{
|
||||
public Button button;
|
||||
public TMP_Text buttonText;
|
||||
public void SetUp(string title, string subTitle, string textContent)
|
||||
private bool _isClickListenerRegistered;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化按钮逻辑。标题、说明及按钮文字均由 Prefab 上的 LocalizedTMPText 配置,
|
||||
/// 不再把字符串当作 I2 的 Term 传入。
|
||||
/// </summary>
|
||||
public void SetUp()
|
||||
{
|
||||
base.SetUp(title, subTitle);
|
||||
|
||||
var localize = buttonText.GetComponent<Localize>();
|
||||
if (localize != null)
|
||||
base.SetUp();
|
||||
|
||||
if (_isClickListenerRegistered)
|
||||
{
|
||||
localize.SetTerm(textContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonText.text = textContent;
|
||||
return;
|
||||
}
|
||||
|
||||
button.onClick.AddListener(() =>
|
||||
{
|
||||
updateValueAction?.Invoke();
|
||||
});
|
||||
button.onClick.AddListener(InvokeUpdateValueAction);
|
||||
_isClickListenerRegistered = true;
|
||||
}
|
||||
|
||||
private void InvokeUpdateValueAction()
|
||||
{
|
||||
updateValueAction?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user