角色死亡

This commit is contained in:
SoulliesOfficial
2025-12-12 01:37:30 -05:00
parent b54c5f796b
commit 40660b41e0
19 changed files with 1147 additions and 26 deletions

View File

@@ -5,6 +5,11 @@ namespace SLSFramework.General
{
public static class StringExtension
{
/// <summary>
/// 本地化字符串,不使用参数替换
/// </summary>
/// <param name="original">原始字符串</param>
/// <returns></returns>
public static string Localize(this string original)
{
if (LocalizationManager.TryGetTranslation(original, out string translated))
@@ -14,5 +19,26 @@ namespace SLSFramework.General
return original;
}
/// <summary>
/// 本地化字符串使用指定的根GameObject进行i2Loc参数替换
/// </summary>
/// <param name="original">原始字符串</param>
/// <param name="rootGameObject">用于参数替换含有LocalizationParamsManager的根GameObject设为null则表明使用全局参数</param>
/// <returns></returns>
public static string Localize(this string original, GameObject rootGameObject)
{
if (rootGameObject != null && rootGameObject.GetComponent<LocalizationParamsManager>() == null)
{
throw new System.ArgumentException("The provided rootGameObject does not contain a LocalizationParamsManager component.");
}
if (LocalizationManager.TryGetTranslation(original, out string translated, true, 0, true, true, rootGameObject))
{
return translated;
}
return original;
}
}
}