阶段性完成
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using I2.Loc;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
@@ -10,9 +7,6 @@ namespace Ichni.UI
|
||||
{
|
||||
public abstract class SettingsUIElementBase : MonoBehaviour
|
||||
{
|
||||
public string title;
|
||||
public string subTitle;
|
||||
|
||||
public Image titleBackground;
|
||||
public TMP_Text titleText;
|
||||
public TMP_Text subTitleText;
|
||||
@@ -21,52 +15,22 @@ namespace Ichni.UI
|
||||
|
||||
/// <summary>
|
||||
/// 初始化设置控件的标题区域。
|
||||
/// <paramref name="preservePrefabTitle"/> 用于已经由 Unity Localization 直接驱动标题的控件:
|
||||
/// 运行时代码不会覆盖或隐藏 Prefab 中的本地化标题。
|
||||
/// <para>
|
||||
/// 标题与说明不再由此基础类写入 I2 Key。请在对应 <see cref="TMP_Text"/> 上配置
|
||||
/// <c>LocalizedTMPText</c>,使静态文案与控件逻辑完全解耦。
|
||||
/// </para>
|
||||
/// <paramref name="preservePrefabTitle"/> 为 true 时保留 Prefab 的标题区域;这是设置页面的默认行为。
|
||||
/// </summary>
|
||||
public virtual void SetUp(string title = "", string subTitle = "", bool preservePrefabTitle = false)
|
||||
public virtual void SetUp(bool preservePrefabTitle = true)
|
||||
{
|
||||
if (preservePrefabTitle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (title != "")
|
||||
{
|
||||
SetTitle(title, subTitle);
|
||||
}
|
||||
else
|
||||
{
|
||||
titleBackground.gameObject.SetActive(false);
|
||||
titleText.gameObject.SetActive(false);
|
||||
subTitleText.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTitle(string title, string subTitle = "")
|
||||
{
|
||||
this.title = title;
|
||||
this.subTitle = subTitle;
|
||||
titleText.gameObject.SetActive(true);
|
||||
var titleLoc = titleText.GetComponent<Localize>();
|
||||
if (titleLoc != null)
|
||||
titleLoc.SetTerm(title);
|
||||
else
|
||||
titleText.text = title;
|
||||
|
||||
if (subTitle != "")
|
||||
{
|
||||
subTitleText.gameObject.SetActive(true);
|
||||
var subLoc = subTitleText.GetComponent<Localize>();
|
||||
if (subLoc != null)
|
||||
subLoc.SetTerm(subTitle);
|
||||
else
|
||||
subTitleText.text = subTitle;
|
||||
}
|
||||
else
|
||||
{
|
||||
subTitleText.gameObject.SetActive(false);
|
||||
}
|
||||
titleBackground.gameObject.SetActive(false);
|
||||
titleText.gameObject.SetActive(false);
|
||||
subTitleText.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user