编辑器更新
This commit is contained in:
parent
c4883bd71d
commit
04d9972f55
@ -71,26 +71,36 @@ namespace Logic.Editor
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
InspectorUtils.InspectorTextWidthRich($"<b>版本号选择: </b>");
|
||||
if (InspectorUtils.InspectorButtonWithTextWidth("保存"))
|
||||
{
|
||||
EditorUtility.SetDirty(_asset);
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
InspectorUtils.InspectorTextWidthRich($"<b>版本号: </b>");
|
||||
_major = (uint)EditorGUILayout.IntField((int)_major, GUILayout.Width(20));
|
||||
_major = (uint)Mathf.Max(1, _major);
|
||||
_minor = (uint)EditorGUILayout.IntField((int)_minor, GUILayout.Width(20));
|
||||
_patch = (uint)EditorGUILayout.IntField((int)_patch, GUILayout.Width(20));
|
||||
EditorGUILayout.EndHorizontal();
|
||||
var versionId = _major * 10000 + _minor * 100 + _patch;
|
||||
var desc = $"{_major}.{_minor}.{_patch}";
|
||||
var versionInfo = _asset.GetVersionInfo(versionId);
|
||||
if (versionInfo == null && InspectorUtils.InspectorButtonWithTextWidth($"创建版本号{desc}"))
|
||||
if (_asset.GetVersionInfo(versionId) != null)
|
||||
{
|
||||
_asset.CreateNewVersion(_major, _minor, _patch);
|
||||
_asset.Versions = _asset.Versions.OrderBy(v => v.VersionId).ToList();
|
||||
InspectorUtils.InspectorTextWidthRich($"<b>已存在版本号{_major}.{_minor}.{_patch}</b>");
|
||||
}
|
||||
if (versionInfo != null)
|
||||
else
|
||||
{
|
||||
EditorGUILayout.BeginVertical(_whiteBoxStyle);
|
||||
InspectorUtils.InspectorTextWidthRich($"<b>版本{versionInfo.FullVersion}描述: </b>");
|
||||
versionInfo.Description = EditorGUILayout.TextArea(versionInfo.Description, GUILayout.Height(60));
|
||||
EditorGUILayout.EndVertical();
|
||||
if (InspectorUtils.InspectorButtonWithTextWidth($"创建版本号{desc}"))
|
||||
{
|
||||
_asset.CreateNewVersion(_major, _minor, _patch);
|
||||
_asset.Versions = _asset.Versions.OrderBy(v => v.VersionId).ToList();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
if (_asset.Versions.Count == 0) return;
|
||||
@ -100,10 +110,22 @@ namespace Logic.Editor
|
||||
_index = Mathf.Clamp(_index, 0, versionList.Length - 1);
|
||||
_index = EditorGUILayout.Popup(_index, versionList);
|
||||
var selectedVersion = _asset.Versions[_index];
|
||||
|
||||
EditorGUILayout.BeginVertical(_whiteBoxStyle);
|
||||
InspectorUtils.InspectorTextWidthRich($"<b>版本{selectedVersion.FullVersion}描述: </b>");
|
||||
selectedVersion.Description = EditorGUILayout.TextArea(selectedVersion.Description, GUILayout.Height(60));
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (InspectorUtils.InspectorButtonWithTextWidth($"开启自动战斗")) AddAutoBattle();
|
||||
#if GAME_AUTO_DEBUG
|
||||
InspectorUtils.InspectorTextWidthRich($"<b><color=red>自动战斗已开启:</color></b>");
|
||||
if (InspectorUtils.InspectorButtonWithTextWidth($"关闭自动战斗")) RemoveAutoBattle();
|
||||
#else
|
||||
InspectorUtils.InspectorTextWidthRich($"<b>自动战斗已关闭:</b>");
|
||||
if (InspectorUtils.InspectorButtonWithTextWidth($"开启自动战斗")) AddAutoBattle();
|
||||
#endif
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (InspectorUtils.InspectorButtonWithTextWidth($"构建测试包"))
|
||||
{
|
||||
@ -137,8 +159,8 @@ namespace Logic.Editor
|
||||
// BuildTarget.StandaloneWindows64,
|
||||
// BuildOptions.None);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@ namespace Logic.Editor
|
||||
private uint _idIndex;
|
||||
private int _showIndex = 0;
|
||||
private List<TMP_FontAsset> _assets = new List<TMP_FontAsset>();
|
||||
private HashSet<char> characterSet = new HashSet<char>();
|
||||
|
||||
|
||||
[MenuItem("Tools/多语言编辑器")]
|
||||
@ -166,6 +167,38 @@ namespace Logic.Editor
|
||||
{
|
||||
_asset.FontGroups.Add(new MultilingualFontGroup());
|
||||
}
|
||||
|
||||
if (InspectorUtils.InspectorButtonWithTextWidth("检查字符集是否有新增"))
|
||||
{
|
||||
string path = "Assets/Fonts/ChineseCharSet.txt";
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
EditorUtility.DisplayDialog("字符集提示", "找不到字符集TXT", "确定");
|
||||
}
|
||||
else
|
||||
{
|
||||
characterSet.Clear();
|
||||
string content = System.IO.File.ReadAllText(path);
|
||||
foreach (var c in content) characterSet.Add(c);
|
||||
bool isNeedUpdate = false;
|
||||
foreach (var item in _asset.Items)
|
||||
{
|
||||
foreach (var c in item.ZH)
|
||||
{
|
||||
if (!IsChinese(c)) continue;
|
||||
if (!characterSet.Contains(c)) isNeedUpdate = true;
|
||||
}
|
||||
}
|
||||
if (isNeedUpdate)EditorUtility.DisplayDialog("字符集提示", "有新增,请创建新的字符集TXT", "确定");
|
||||
else EditorUtility.DisplayDialog("字符集提示", "无新增,无需理会", "确定");
|
||||
}
|
||||
}
|
||||
|
||||
if (InspectorUtils.InspectorButtonWithTextWidth("创建新的字符集TXT"))
|
||||
{
|
||||
OnBuildChineseTxt();
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginVertical(_whiteBoxStyle);
|
||||
@ -570,5 +603,78 @@ namespace Logic.Editor
|
||||
Debug.Log($"Error: {error}"); // 打印错误信息
|
||||
}
|
||||
}
|
||||
|
||||
private void OnBuildChineseTxt()
|
||||
{
|
||||
characterSet.Clear();
|
||||
AddBasicCharacters();
|
||||
ExtractChineseFromI2Languages();
|
||||
ExportCharacterSet();
|
||||
}
|
||||
|
||||
private void AddBasicCharacters()
|
||||
{
|
||||
// 添加大写字母
|
||||
for (char c = 'A'; c <= 'Z'; c++)
|
||||
{
|
||||
characterSet.Add(c);
|
||||
}
|
||||
|
||||
// 添加小写字母
|
||||
for (char c = 'a'; c <= 'z'; c++)
|
||||
{
|
||||
characterSet.Add(c);
|
||||
}
|
||||
|
||||
// 添加数字
|
||||
for (char c = '0'; c <= '9'; c++)
|
||||
{
|
||||
characterSet.Add(c);
|
||||
}
|
||||
|
||||
// 添加常用标点符号
|
||||
string punctuations = ",.!?;:\"'()[]{}+-*/=_<>@#$%^&|\\~|/\~{}[]【】「」『』《》〈〉:;“” ‘’"、,。?!…—--_+-=×÷";
|
||||
foreach (char c in punctuations)
|
||||
{
|
||||
characterSet.Add(c);
|
||||
}
|
||||
}
|
||||
|
||||
private void ExtractChineseFromI2Languages()
|
||||
{
|
||||
var path = $"Assets/Resources/Export/Multilingual.asset";
|
||||
var asset = AssetDatabase.LoadAssetAtPath<MultilingualData>(path);
|
||||
if (asset == null)
|
||||
{
|
||||
EditorUtility.DisplayDialog("错误", "未找到多语言资源文件,请确认路径是否正确。", "确定");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var item in asset.Items)
|
||||
{
|
||||
foreach (var c in item.ZH)
|
||||
{
|
||||
if (!IsChinese(c)) continue;
|
||||
characterSet.Add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsChinese(char c)
|
||||
{
|
||||
return (c >= 0x4E00 && c <= 0x9FFF) || // CJK统一汉字
|
||||
(c >= 0x3400 && c <= 0x4DBF) || // CJK扩展A
|
||||
(c >= 0x20000 && c <= 0x2A6DF); // CJK扩展B
|
||||
}
|
||||
|
||||
private void ExportCharacterSet()
|
||||
{
|
||||
string path = EditorUtility.SaveFilePanel("保存字符集", "Assets/Fonts", "ChineseCharSet", "txt");
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
File.WriteAllText(path, string.Join("", characterSet.OrderBy(c => c)), Encoding.UTF8);
|
||||
EditorUtility.DisplayDialog("成功", "字符集已导出!", "确定");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user