Merge branch 'main' of http://10.27.16.144:3000/kawagiri/TH1
This commit is contained in:
commit
10002e547b
@ -156,7 +156,7 @@ namespace Logic.Editor
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
|
||||
|
||||
var deleteSet = new HashSet<MultilingualFontGroup>();
|
||||
for (int i = 0; i < _asset.FontGroups.Count; i++)
|
||||
|
||||
@ -102,13 +102,20 @@ namespace Logic.Editor
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (_previewType != MultilingualType.ZH && InspectorUtils.InspectorButtonWithTextWidth($"保存当前字体相关配置{_previewType}"))
|
||||
if (InspectorUtils.InspectorButtonWithTextWidth($"保存当前字体相关配置{_previewType}"))
|
||||
{
|
||||
var text = mono.GetComponent<TextMeshProUGUI>();
|
||||
if (text)
|
||||
{
|
||||
for (int i = mono.TextCfg.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (mono.TextCfg[i].Type == _previewType) mono.TextCfg.RemoveAt(i);
|
||||
}
|
||||
var cfg = new MultiTextConfig(text, _previewType);
|
||||
mono.TextCfg.Add(cfg);
|
||||
|
||||
// 按Type从小到大排序
|
||||
mono.TextCfg.Sort((a, b) => a.Type.CompareTo(b.Type));
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
@ -28,6 +28,7 @@ namespace Logic.Multilingual
|
||||
{
|
||||
public List<MultilingualFontGroup> FontGroups = new List<MultilingualFontGroup>();
|
||||
public List<MultilingualItem> Items = new List<MultilingualItem>();
|
||||
public List<MultilingualType> TargetTypes = new List<MultilingualType>();
|
||||
private Dictionary<uint, MultilingualItem> _itemDict;
|
||||
public Dictionary<uint, MultilingualItem> ItemDict => _itemDict;
|
||||
|
||||
@ -86,6 +87,13 @@ namespace Logic.Multilingual
|
||||
_itemDict.Clear();
|
||||
foreach (var item in Items) _itemDict[item.ID] = item;
|
||||
}
|
||||
|
||||
public MultilingualType GetSystemLanguageTargetMultilingual(MultilingualType type)
|
||||
{
|
||||
var index = (int)type;
|
||||
if (index >= TargetTypes.Count) return type;
|
||||
return TargetTypes[index];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -27,10 +27,12 @@ namespace Logic.Multilingual
|
||||
public void Init()
|
||||
{
|
||||
RefreshMultilingualData();
|
||||
_currentType = (MultilingualType)PlayerPrefs.GetInt("Multilingual", 0);
|
||||
var multilingualValue = PlayerPrefs.GetInt("Multilingual", -1);
|
||||
if (multilingualValue == -1) _currentType = GetSystemLanguage();
|
||||
else _currentType = (MultilingualType)multilingualValue;
|
||||
ChangedMultilingual(_currentType);
|
||||
}
|
||||
|
||||
|
||||
public string GetMultilingualText(uint id)
|
||||
{
|
||||
RefreshMultilingualData();
|
||||
@ -49,6 +51,8 @@ namespace Logic.Multilingual
|
||||
RefreshTextComs();
|
||||
_currentType = type;
|
||||
foreach (var textCom in _textComs) textCom.OnMultilingualChanged();
|
||||
PlayerPrefs.SetInt("Multilingual", (int)_currentType);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
public uint GetFontGroupID(TMP_FontAsset font)
|
||||
@ -96,5 +100,29 @@ namespace Logic.Multilingual
|
||||
|
||||
_textComs = uiObj.GetComponentsInChildren<MultilingualTextMono>(true).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据系统语言自动切换多语言设置(仅PC平台)
|
||||
/// </summary>
|
||||
public MultilingualType GetSystemLanguage()
|
||||
{
|
||||
#if UNITY_STANDALONE_WIN
|
||||
// 获取系统语言
|
||||
var systemLanguage = Application.systemLanguage;
|
||||
|
||||
// 根据系统语言切换对应的多语言类型
|
||||
var systemType = systemLanguage switch
|
||||
{
|
||||
SystemLanguage.Chinese => MultilingualType.ZH,
|
||||
SystemLanguage.ChineseTraditional => MultilingualType.TDZH,
|
||||
SystemLanguage.Japanese => MultilingualType.JP,
|
||||
SystemLanguage.Korean => MultilingualType.KR,
|
||||
_ => MultilingualType.EN // 其他语言默认使用英语
|
||||
};
|
||||
|
||||
return _multilingualData.GetSystemLanguageTargetMultilingual(systemType);
|
||||
#endif
|
||||
return MultilingualType.ZH; // 默认返回英语
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user