setting change

This commit is contained in:
Bob.Song
2026-02-02 17:58:39 +08:00
parent f33f61f515
commit 55a92d9b23
127 changed files with 803 additions and 222 deletions

View File

@@ -61,6 +61,7 @@ namespace NBC.Asset
{
return assetProvider.Asset as T;
}
return null;
}
@@ -385,6 +386,9 @@ namespace NBC.Asset
_monoGameObject = new GameObject("Assets", typeof(Mono));
Mono.AddUpdate(Update);
InitializationTask task;
#if UNITY_STANDALONE_WIN
Const.NotCache = true;
#endif
if (Const.Simulate)
{
task = new EditorInitializationTask();

View File

@@ -9,7 +9,8 @@ namespace NBC.Asset
public const string VersionFileName = "version.json";
public static bool IsWebGLPlatform => Application.platform == RuntimePlatform.WebGLPlayer;
public static readonly string SavePath =
$"{Application.persistentDataPath}{Path.DirectorySeparatorChar}{BundleDirName}{Path.DirectorySeparatorChar}";
@@ -20,9 +21,10 @@ namespace NBC.Asset
public static bool Offline;
public static bool Simulate;
public static bool NotCache;
public static int DownloadTimeOut = 10;
public static string GetStreamingPath(string file)
{
@@ -31,6 +33,11 @@ namespace NBC.Asset
public static string GetCachePath(string file)
{
if (NotCache)
{
return GetStreamingPath(file);
}
return $"{SavePath}{file}";
}
@@ -45,6 +52,7 @@ namespace NBC.Asset
{
return $"{RemoteUrl}/{file}";
}
return $"{RemoteUrl}{BundleDirName}/{file}";
}
}

View File

@@ -1,7 +1,7 @@
namespace NBC.Asset
{
/// <summary>
/// 离线模式初始化任务
/// 移动端离线模式初始化任务
/// </summary>
internal sealed class OfflineInitializationTask : InitializationTask
{
@@ -10,9 +10,13 @@
protected override void OnStart()
{
_taskList.AddTask(new CheckCoverInstallTask());
_taskList.AddTask(new UnpackVersionTask());
_taskList.AddTask(new CheckUnpackPackageTask());
if (!Const.NotCache)
{
_taskList.AddTask(new CheckCoverInstallTask());
_taskList.AddTask(new UnpackVersionTask());
_taskList.AddTask(new CheckUnpackPackageTask());
}
_taskList.AddTask(new RunFunctionTask(Addressable.Load));
_taskList.Run(TaskRunner.Def);
}

View File

@@ -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)

View File

@@ -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>();

View File

@@ -16,11 +16,7 @@ namespace NBC
bool IsShowing { get; }
bool IsCanVisible { get; }
bool IsDotDel { get; }
/// <summary>
/// 不能返回
/// </summary>
bool IsDontBack { get; }
bool IsModal { get; }
@@ -30,6 +26,7 @@ namespace NBC
void SetData(object args);
object GetData();
string[] GetDependPackages();
void SetLanguage();
void Init();
void Show();

View File

@@ -190,6 +190,7 @@ namespace NBC
Show();
}
/// <summary>
/// 设置刷新多语言
/// </summary>

View File

@@ -137,7 +137,14 @@ namespace NBC
if (curField == null) return;
var textFormat = curField.textFormat;
var font = Lan.GetLanFontByCurFont(textFormat.font);
Log.Info($"font={textFormat.font}");
var fontName = textFormat.font;
if (string.IsNullOrEmpty(fontName))
{
fontName = UIConfig.defaultFont;
}
var font = Lan.GetLanFontByCurFont(fontName);
if (font == null) return;
textFormat.font = font;
curField.textFormat = textFormat;