首次提交

This commit is contained in:
Bob.Song
2026-03-05 18:07:55 +08:00
commit e125bb869e
4534 changed files with 563920 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
using System.Collections.Generic;
using FairyGUI;
using TMPro;
using UnityEngine;
namespace NBC
{
public class LanguageFont : ILanguage
{
/// <summary>
/// 多语言字体配置数据
/// </summary>
private readonly Dictionary<SystemLanguage, Dictionary<string, string>> _languages =
new Dictionary<SystemLanguage, Dictionary<string, string>>();
/// <summary>
/// 当前语言和字体
/// </summary>
private Dictionary<string, string> _currentLanguageDictionary = new Dictionary<string, string>();
public string Get(string key)
{
if (_currentLanguageDictionary != null && _currentLanguageDictionary.TryGetValue(key, out var value))
{
return value;
}
return null;
}
public void AddLanguage(SystemLanguage language)
{
var configDic = Lan.Inst.GetLanguageFontConfig(LanguageConst.languageMap[language]);
// 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);
// }
}
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);
}
_languages[language] = keys;
}
public bool UseLanguage(SystemLanguage language)
{
if (_languages.TryGetValue(language, out var language1))
{
_currentLanguageDictionary = language1;
return true;
}
Debug.LogError("字体配置不存在");
return false;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 396d5c74b8514345b8fe20c34101621c
timeCreated: 1715248083

View File

@@ -0,0 +1,59 @@
using System.Collections.Generic;
using UnityEngine;
namespace NBC
{
public class LanguageImage : ILanguage
{
/// <summary>
/// 多语言图片配置数据
/// </summary>
private readonly Dictionary<SystemLanguage, Dictionary<string, string>> _languages =
new Dictionary<SystemLanguage, Dictionary<string, string>>();
/// <summary>
/// 当前语言图片配置键值对
/// </summary>
private Dictionary<string, string> _currentLanguageDictionary = new Dictionary<string, string>();
/// <summary>
/// 获得对应图片路径
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public string Get(string key)
{
if (_currentLanguageDictionary != null && _currentLanguageDictionary.TryGetValue(key, out var value))
{
return "Assets/ResRaw/languageImage/" + value;
}
return null;
}
public void AddLanguage(SystemLanguage language)
{
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)
{
if (_languages.TryGetValue(language, out var language1))
{
_currentLanguageDictionary = language1;
return true;
}
Debug.LogError("语言图片配置不存在");
return false;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6f07e3230ea741df9793099846dd6f5d
timeCreated: 1715248110

View File

@@ -0,0 +1,54 @@
using System.Collections.Generic;
using UnityEngine;
namespace NBC
{
public class LanguageText : ILanguage
{
/// <summary>
/// 多语言配置数据
/// </summary>
private readonly Dictionary<SystemLanguage, Dictionary<string, string>> _languages =
new Dictionary<SystemLanguage, Dictionary<string, string>>();
/// <summary>
/// 当前语言包键值对
/// </summary>
private Dictionary<string, string> _currentLanguageDictionary = new Dictionary<string, string>();
public string Get(string key)
{
if (_currentLanguageDictionary != null && _currentLanguageDictionary.TryGetValue(key, out var value))
{
return value;
}
return key;
}
public void AddLanguage(SystemLanguage language)
{
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.TryGetValue(language, out var language1))
{
_currentLanguageDictionary = language1;
return true;
}
Debug.LogError("语言包不存在");
return false;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2bbfc1f115024ce4a6cc38d5be592641
timeCreated: 1715248144