多语言相关
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBC
|
||||
@@ -28,40 +30,40 @@ namespace NBC
|
||||
|
||||
public void AddLanguage(SystemLanguage language)
|
||||
{
|
||||
// var configDic = GameConfig.Inst.GetLanguageFontConfig(LanguageConst.languageMap[language]);
|
||||
// string fontLocation = "Assets/ResRaw/Fonts/";
|
||||
// //字体使用前需要先注册
|
||||
// foreach (var config in configDic.Values)
|
||||
// {
|
||||
// if (config.type == "1")
|
||||
// {
|
||||
// DynamicFont font = new DynamicFont();
|
||||
// font.name = config.name;
|
||||
// font.nativeFont = Assets.LoadAsset<Font>(fontLocation + config.relativePath).Asset as Font;
|
||||
// FontManager.RegisterFont(font);
|
||||
// }
|
||||
// else if (config.type == "2")
|
||||
// {
|
||||
// TMP_FontAsset fontAsset =
|
||||
// Assets.LoadAsset<TMP_FontAsset>(fontLocation + config.relativePath).Asset as TMP_FontAsset;
|
||||
// TMPFont font = new TMPFont();
|
||||
// font.name = config.name; //这个名字要和编辑器里字体资源的名字一致
|
||||
// font.fontAsset = fontAsset;
|
||||
// FontManager.RegisterFont(font);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// var font2KeyDic = GameConfig.Inst.GetFont2KeyDic();
|
||||
// Dictionary<string, string> keys = new Dictionary<string, string>();
|
||||
// foreach (var pair in font2KeyDic)
|
||||
// {
|
||||
// keys.Add(pair.Key, configDic[pair.Value].name);
|
||||
// }
|
||||
//
|
||||
// if (keys != null)
|
||||
// {
|
||||
// _languages[language] = keys;
|
||||
// }
|
||||
var configDic = Lan.Inst.GetLanguageFontConfig(LanguageConst.languageMap[language]);
|
||||
string fontLocation = "Assets/Resources/Fonts/";
|
||||
//字体使用前需要先注册
|
||||
foreach (var config in configDic.Values)
|
||||
{
|
||||
if (config.Type == "1")
|
||||
{
|
||||
DynamicFont font = new DynamicFont();
|
||||
font.name = config.Name;
|
||||
font.nativeFont = Resources.Load<Font>(fontLocation + config.RelativePath);
|
||||
FontManager.RegisterFont(font);
|
||||
}
|
||||
else if (config.Type == "2")
|
||||
{
|
||||
TMP_FontAsset fontAsset =
|
||||
Resources.Load<TMP_FontAsset>(fontLocation + config.RelativePath) as TMP_FontAsset;
|
||||
TMPFont font = new TMPFont();
|
||||
font.name = config.Name; //这个名字要和编辑器里字体资源的名字一致
|
||||
font.fontAsset = fontAsset;
|
||||
FontManager.RegisterFont(font);
|
||||
}
|
||||
}
|
||||
|
||||
var font2KeyDic = Lan.Inst.GetFont2KeyDic();
|
||||
Dictionary<string, string> keys = new Dictionary<string, string>();
|
||||
foreach (var pair in font2KeyDic)
|
||||
{
|
||||
keys.Add(pair.Key, configDic[pair.Value].Name);
|
||||
}
|
||||
|
||||
if (keys != null)
|
||||
{
|
||||
_languages[language] = keys;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UseLanguage(SystemLanguage language)
|
||||
|
||||
@@ -33,15 +33,15 @@ namespace NBC
|
||||
|
||||
public void AddLanguage(SystemLanguage language)
|
||||
{
|
||||
// var keys = GameConfig.Inst.GetLanguageImageConfig(LanguageConst.languageMap[language]);
|
||||
// if (keys != null)
|
||||
// {
|
||||
// _languages[language] = keys;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _languages[language] = new Dictionary<string, string>();
|
||||
// }
|
||||
var keys = Lan.Inst.GetLanguageImageConfig(LanguageConst.languageMap[language]);
|
||||
if (keys != null)
|
||||
{
|
||||
_languages[language] = keys;
|
||||
}
|
||||
else
|
||||
{
|
||||
_languages[language] = new Dictionary<string, string>();
|
||||
}
|
||||
}
|
||||
|
||||
public bool UseLanguage(SystemLanguage language)
|
||||
|
||||
@@ -28,22 +28,22 @@ namespace NBC
|
||||
|
||||
public void AddLanguage(SystemLanguage language)
|
||||
{
|
||||
// var keys = GameConfig.Inst.GetLanguageConfig(LanguageConst.languageMap[language]);
|
||||
// if (keys != null)
|
||||
// {
|
||||
// _languages[language] = keys;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _languages[language] = new Dictionary<string, string>();
|
||||
// }
|
||||
var keys = Lan.Inst.GetLanguageConfig(LanguageConst.languageMap[language]);
|
||||
if (keys != null)
|
||||
{
|
||||
_languages[language] = keys;
|
||||
}
|
||||
else
|
||||
{
|
||||
_languages[language] = new Dictionary<string, string>();
|
||||
}
|
||||
}
|
||||
|
||||
public bool UseLanguage(SystemLanguage language)
|
||||
{
|
||||
if (_languages.ContainsKey(language))
|
||||
if (_languages.TryGetValue(language, out var language1))
|
||||
{
|
||||
_currentLanguageDictionary = _languages[language];
|
||||
_currentLanguageDictionary = language1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user