2024-11-13 14:49:14 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
public class LocalizeTextData
|
|
|
|
|
|
{
|
|
|
|
|
|
private Dictionary<string, string> TexDic;
|
|
|
|
|
|
|
|
|
|
|
|
public string GetString(string key)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (TexDic.TryGetValue(key, out var text))
|
|
|
|
|
|
{
|
|
|
|
|
|
return text;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-13 15:41:08 +08:00
|
|
|
|
Debug.LogError($"AOT部分文本配置缺少Key:{key}");
|
2024-11-13 14:49:14 +08:00
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 多语言索引,索引值参考Localize脚本, 0默认, 1中文,2繁中,3英文
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="index"></param>
|
|
|
|
|
|
public LocalizeTextData(int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (index)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 1: //简体中文
|
|
|
|
|
|
TexDic = TextLocalizeDic.CN;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 2: //繁体中文
|
|
|
|
|
|
TexDic = TextLocalizeDic.TW;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 3: //英文
|
|
|
|
|
|
TexDic = TextLocalizeDic.EN;
|
|
|
|
|
|
break;
|
|
|
|
|
|
default: //默认
|
|
|
|
|
|
TexDic = TextLocalizeDic.CN;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static class TextLocalizeDic
|
|
|
|
|
|
{
|
|
|
|
|
|
public static Dictionary<string, string> CN = new()
|
|
|
|
|
|
{
|
|
|
|
|
|
["key_0"] = "简中文本1",
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
public static Dictionary<string, string> TW = new()
|
|
|
|
|
|
{
|
|
|
|
|
|
["key_0"] = "繁中文本1",
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
public static Dictionary<string, string> EN = new()
|
|
|
|
|
|
{
|
|
|
|
|
|
["key_0"] = "Text 1",
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|