setting change
This commit is contained in:
@@ -14,7 +14,7 @@ namespace NBC
|
||||
new Dictionary<SystemLanguage, Dictionary<string, string>>();
|
||||
|
||||
/// <summary>
|
||||
/// 当前语言图片配置键值对
|
||||
/// 当前语言和字体
|
||||
/// </summary>
|
||||
private Dictionary<string, string> _currentLanguageDictionary = new Dictionary<string, string>();
|
||||
|
||||
@@ -31,26 +31,26 @@ namespace NBC
|
||||
public void AddLanguage(SystemLanguage language)
|
||||
{
|
||||
var configDic = Lan.Inst.GetLanguageFontConfig(LanguageConst.languageMap[language]);
|
||||
string fontLocation = "Fonts/";//"Assets/Resources/Fonts/";
|
||||
// string fontLocation = "Fonts/";//"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);
|
||||
}
|
||||
// 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();
|
||||
@@ -59,11 +59,8 @@ namespace NBC
|
||||
{
|
||||
keys.Add(pair.Key, configDic[pair.Value].Name);
|
||||
}
|
||||
|
||||
if (keys != null)
|
||||
{
|
||||
_languages[language] = keys;
|
||||
}
|
||||
|
||||
_languages[language] = keys;
|
||||
}
|
||||
|
||||
public bool UseLanguage(SystemLanguage language)
|
||||
|
||||
@@ -14,10 +14,11 @@ namespace NBC
|
||||
|
||||
private Dictionary<int, ILanguage> _lanModuleDic = new Dictionary<int, ILanguage>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 变化通知事件
|
||||
/// </summary>
|
||||
private Action _changeAction;
|
||||
public event Action ChangeAction;
|
||||
|
||||
public LanguageManager()
|
||||
{
|
||||
@@ -79,7 +80,7 @@ namespace NBC
|
||||
value.UseLanguage(language);
|
||||
}
|
||||
|
||||
_changeAction?.Invoke();
|
||||
ChangeAction?.Invoke();
|
||||
}
|
||||
|
||||
public void AddLanguage(SystemLanguage language, bool isDefault = false)
|
||||
@@ -95,16 +96,6 @@ namespace NBC
|
||||
}
|
||||
}
|
||||
|
||||
public void OnChange(Action callback)
|
||||
{
|
||||
_changeAction += callback;
|
||||
}
|
||||
|
||||
public void OffChange(Action callback)
|
||||
{
|
||||
_changeAction -= callback;
|
||||
}
|
||||
|
||||
#region config
|
||||
|
||||
private readonly Dictionary<string, LanguageConfig> _languageConfigs = new Dictionary<string, LanguageConfig>();
|
||||
|
||||
Reference in New Issue
Block a user