This commit is contained in:
bob
2025-06-05 15:39:47 +08:00
parent 55f49e1af7
commit f9c0975f10
50 changed files with 575 additions and 51 deletions

Binary file not shown.

View File

@@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: 989e8824f65d75c4aa557ea69ac7bf15
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Alibaba Sans
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: eef999d3423421146bd519feb78cc6fc
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Alibaba Sans
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: ea6183bf0786fbc498dfa4e0707f977d
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Alibaba Sans
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: 7abea0d1f6ff81f4ea7694daac8b8cec
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Alibaba Sans JP
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: 3d140caabac80fe48bd4ffca7420dfb6
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Alibaba Sans JP
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: f557a1bcb35e0c641be4bede814b6da3
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Alibaba Sans JP
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: a1ef4058716710045ba810f30e6cf5d9
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Alibaba Sans KR
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: 164874a9b9b15ca4b9d167b7452ff536
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Alibaba Sans KR
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: 6d7f777b10208d04e91718b1ccd3adc1
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Alibaba Sans KR
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: fa3ea1934c4d7904697978eb0af23637
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Alibaba Sans TC
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: 55206fa2bfb619246ad36af477713cca
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Alibaba Sans TC
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: b87b921769415d94ebe503ee4de52222
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Alibaba Sans TC
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: a2c649761ed51a343ab681b1b1721113
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Alibaba Sans Thai
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: 7520f17e2e2e08649af96b4ccc944826
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Alibaba Sans Thai
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: 1de30e4e7e814ce47acb2cb6017ee55c
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Alibaba Sans Thai
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: d53d5b8b88461714291fd8297a221fa4
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Alibaba Sans Viet
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: 7a84e8d6733a8204eb49d18efea5a27e
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Alibaba Sans Viet
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: 2a8db4fb9e5851a4ead17b802428ae18
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Alibaba Sans Viet
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,53 @@
{
"language": [
{
"key": "HOME_ICON_GROCERY",
"en": "Store",
"chs": "杂货店"
},
{
"key": "HOME_ICON_QUEST",
"en": "Mission",
"chs": "任务"
},
{
"key": "HOME_BUTTON_START",
"en": "Start",
"chs": "开始旅程"
},
{
"key": "HOME_PAGE_ALLIANCE",
"en": "Clan",
"chs": "公会"
}
],
"languageFont": [
{
"key": "CarterOne",
"en": "1,CarterOne-Regular,en/CarterOne-Regular.ttf",
"chs": "1,SourceHanSansCN-Bold,chs/SourceHanSansCN-Bold.ttf"
},
{
"key": "CarterOnePro",
"en": "2,CarterOne-RegularPRO,en/CarterOne-RegularPRO.asset",
"chs": "2,SourceHanSansCN-BoldPro,chs/SourceHanSansCN-Bold.asset"
},
{
"key": "CarterTwo",
"en": "1,CarterTwo-Regular,en/CarterTwo-Regular.ttf",
"chs": "1,SourceHanSansCN-Bold2,chs/SourceHanSansCN-Bold.ttf"
},
{
"key": "CarterTwoPro",
"en": "2,CarterTwo-RegularPRO,en/CarterTwo-RegularPRO.asset",
"chs": "2,SourceHanSansCN-Bold2Pro,chs/SourceHanSansCN-Bold.asset"
}
],
"languageImage": [
{
"key": "LoadingTitle",
"en": "en/login_logo_fengbao.png",
"chs": "chs/login_logo.png"
}
]
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: cf64024c73d025f4fb74b9f0f3056936
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -22,28 +22,13 @@ namespace NBF
ExcelToJsonWindow.GenConfig(false);
AssetDatabase.Refresh();
}
// [MenuItem("构建/配置表/读取")]
// public static void Read()
// {
// var assets = EditorUtils.GetOrCreateAsset<ConfigAssets>(ConfigAssets.SavePath);
//
// var path = Path.Combine(Application.dataPath, "Resources/config", "Input.json");
// var json = File.ReadAllText(path);
//
// JsonUtility.FromJsonOverwrite(json, assets);
// EditorUtility.SetDirty(assets);
// AssetDatabase.SaveAssets(); // 保存更改
// AssetDatabase.Refresh();
// }
// [MenuItem("构建/配置表/转json")]
// public static void GenJson()
// {
// CfgAssets cfgAssets = AssetDatabase.LoadAssetAtPath<CfgAssets>("Assets/Resources/config/CfgAssets.asset");
// var json = JsonUtility.ToJson(cfgAssets);
// File.WriteAllText(Path.Combine(Application.dataPath, "Resources/config", "Input.json"), json);
// // CfgAssets cfgAssets = Resources.Load<CfgAssets>("config/CfgAssets");
// }
[MenuItem("构建/配置表/导多语言")]
public static void BuildLanguage()
{
ExcelToJsonWindow.GenLanguage();
AssetDatabase.Refresh();
}
#region

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8a74bb7a59dd4f689beec3add0e7c8c6
timeCreated: 1749097649

View File

@@ -6,6 +6,7 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using ExcelDataReader;
using NBC;
using Newtonsoft.Json;
@@ -18,12 +19,15 @@ namespace NBF
{
public static class ExcelToJsonWindow
{
#region
public static void GenConfig(bool showMessageBox = true)
{
CfgEditorUtil.GenConfigScripts();
GenConfig(Application.dataPath + "/../Config", showMessageBox);
}
public static void GenConfig(string path, bool showMessageBox = false)
{
List<string> list = new List<string>();
@@ -54,7 +58,6 @@ namespace NBF
private static void BuildAsset()
{
//Application.dataPath
var json = JsonConvert.SerializeObject(AllJsonData, Formatting.Indented, new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
@@ -80,21 +83,10 @@ namespace NBF
}
}
// 将路径中的所有反斜杠转换为正斜杠
// string normalizedAbsolutePath = savePath.Replace("\\", "/");
// string normalizedDataPath = Application.dataPath.Replace("\\", "/");
// string relativePath = normalizedAbsolutePath.Replace(normalizedDataPath, "");
// ConfigAssets.SavePath
// var relativePath = "Assets/ResRaw/config/ConfigAssets.asset";
//$"Assets/Resources/Config/ConfigAssets.asset";
var relativePath = ConfigAssets.SavePath;
var asset = EditorUtils.GetOrCreateAsset<ConfigAssets>(relativePath);
var types = Reflection.GetAllNonAbstractDerivedTypes<ConfigBase>();
foreach (var type in types)
{
@@ -115,6 +107,48 @@ namespace NBF
AssetDatabase.Refresh();
}
#endregion
#region
public static void GenLanguage()
{
var path = Application.dataPath + "/../Config/language";
List<string> list = new List<string>();
GetFiles(path, fileList: ref list);
AllJsonData.Clear();
Stopwatch s = Stopwatch.StartNew();
ReadExcel(list.ToArray());
var savePath = Path.Combine(Application.dataPath, "Resources/config/language.json");
BuildJson(savePath);
s.Stop();
Debug.Log($"导多语言完成,耗时{(s.ElapsedMilliseconds / 1000f):.00}秒");
AssetDatabase.Refresh();
}
private static void BuildJson(string savaPath)
{
var json = JsonConvert.SerializeObject(AllJsonData, Formatting.Indented, new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
});
SaveJson(savaPath, json);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
#endregion
#region
private static void GetFiles(string path, ref List<string> fileList)
@@ -136,8 +170,25 @@ namespace NBF
}
}
#endregion
private static void SaveJson(string jsonPath, string json)
{
try
{
if (File.Exists(jsonPath))
{
File.Delete(jsonPath);
}
File.WriteAllBytes(jsonPath, Encoding.UTF8.GetBytes(json));
}
catch (Exception e)
{
// Console.WriteLine(e);
// throw;
}
}
#endregion
#region Excel读取

View File

@@ -13,7 +13,12 @@ namespace NBC
public class LanguageConst
{
public const string LanguageSaveKey = "LanguageSaveKey";
//简体中文、繁体中文、英语、日语、韩语、泰语、越南语、法语、德语、葡萄牙与、西班牙语、俄语、波兰语、荷兰语、
//土耳其语、意大利语、印度尼西亚语
/// <summary>
/// 自定义语言和名字映射关系
/// </summary>
@@ -22,39 +27,71 @@ namespace NBC
{
{
SystemLanguage.English,
new LanguageInfo() { Language = SystemLanguage.English, Name = "", Code = "en" }
new LanguageInfo() { Language = SystemLanguage.English, Name = "English", Code = "en" }
},
{
SystemLanguage.ChineseSimplified,
new LanguageInfo() { Language = SystemLanguage.ChineseSimplified, Name = "", Code = "zh-CN" }
new LanguageInfo() { Language = SystemLanguage.ChineseSimplified, Name = "简体中文", Code = "zh-CN" }
},
{
SystemLanguage.ChineseTraditional,
new LanguageInfo() { Language = SystemLanguage.ChineseTraditional, Name = "", Code = "zh-TW" }
new LanguageInfo() { Language = SystemLanguage.ChineseTraditional, Name = "繁體中文", Code = "zh-TW" }
},
{
SystemLanguage.Japanese,
new LanguageInfo() { Language = SystemLanguage.Japanese, Name = "", Code = "jp" }
new LanguageInfo() { Language = SystemLanguage.Japanese, Name = "日本語", Code = "ja" }
},
{
SystemLanguage.Korean,
new LanguageInfo() { Language = SystemLanguage.Korean, Name = "", Code = "kr" }
new LanguageInfo() { Language = SystemLanguage.Korean, Name = "한국어", Code = "ko" }
},
{
SystemLanguage.French,
new LanguageInfo() { Language = SystemLanguage.French, Name = "", Code = "fr" }
},
{
SystemLanguage.Russian,
new LanguageInfo() { Language = SystemLanguage.Russian, Name = "", Code = "fr" }
},
{
SystemLanguage.Spanish,
new LanguageInfo() { Language = SystemLanguage.Spanish, Name = "", Code = "fr" }
SystemLanguage.Thai,
new LanguageInfo() { Language = SystemLanguage.Thai, Name = "ไทย", Code = "th" }
},
{
SystemLanguage.Vietnamese,
new LanguageInfo() { Language = SystemLanguage.Vietnamese, Name = "", Code = "fr" }
new LanguageInfo() { Language = SystemLanguage.Vietnamese, Name = "Tiếng Việt", Code = "vi" }
},
{
SystemLanguage.German,
new LanguageInfo() { Language = SystemLanguage.German, Name = "Deutsch", Code = "de" }
},
{
SystemLanguage.French,
new LanguageInfo() { Language = SystemLanguage.French, Name = "Français", Code = "fr" }
},
{
SystemLanguage.Russian,
new LanguageInfo() { Language = SystemLanguage.Russian, Name = "Русский", Code = "ru" }
},
{
SystemLanguage.Spanish,
new LanguageInfo() { Language = SystemLanguage.Spanish, Name = "Español", Code = "es" }
},
{
SystemLanguage.Portuguese,
new LanguageInfo() { Language = SystemLanguage.Portuguese, Name = "Português", Code = "pt" }
},
{
SystemLanguage.Polish,
new LanguageInfo() { Language = SystemLanguage.Polish, Name = "Polski", Code = "pl" }
},
{
SystemLanguage.Dutch,
new LanguageInfo() { Language = SystemLanguage.Dutch, Name = "Nederlands", Code = "nl" }
},
{
SystemLanguage.Turkish,
new LanguageInfo() { Language = SystemLanguage.Turkish, Name = "Türkçe", Code = "tr" }
},
{
SystemLanguage.Indonesian,
new LanguageInfo() { Language = SystemLanguage.Indonesian, Name = "Bahasa Indonesia", Code = "id" }
},
{
SystemLanguage.Italian,
new LanguageInfo() { Language = SystemLanguage.Italian, Name = "Italiano", Code = "it" }
},
};
}