Passion & UI

This commit is contained in:
SoulliesOfficial
2026-06-12 17:11:39 -04:00
parent 7bc1e1722c
commit 6d7ebc5825
3444 changed files with 865284 additions and 463132 deletions

View File

@@ -6,7 +6,7 @@ namespace SLSUtilities.General
public class Singleton<T> : SerializedMonoBehaviour where T : MonoBehaviour
{
protected static T instance;
public static T Instance => instance == null ? FindFirstObjectByType<T>() : instance;
public static T Instance => instance;
protected virtual void Awake()
{

View File

@@ -1,18 +1,35 @@
using I2.Loc;
using UnityEngine;
using UnityEngine.Localization.Settings;
namespace SLSUtilities.General
{
public static class StringExtension
{
public static string Localize(this string original)
/// <summary>
/// 根据 Key 从指定 Table 中获取本地化文本。
/// 若本地化系统尚未初始化或 Key 不存在,则原样返回。
/// </summary>
public static string Localize(this string key, string tableName)
{
if (LocalizationManager.TryGetTranslation(original, out string translated))
if (string.IsNullOrEmpty(key))
{
return translated;
return key;
}
return original;
if (!LocalizationSettings.HasSettings ||
LocalizationSettings.SelectedLocale == null)
{
return key;
}
string result = LocalizationSettings.StringDatabase.GetLocalizedString(tableName, key);
if (string.IsNullOrEmpty(result))
{
return key;
}
return result;
}
}
}
}