Skip to content

强化 Unity 文本定位、Addressables 与 TMP 字体工作流 - #5

Merged
timeance merged 1 commit into
mainfrom
agent/harden-unity-text-locator
Jul 18, 2026
Merged

timeance merged 1 commit into
mainfrom
agent/harden-unity-text-locator

Conversation

@timeance

Copy link
Copy Markdown
Owner

变更内容

  • 新增固定字节 DMSL 文本提取与回写工具,支持 occurrence manifest、源文件哈希、字节预算、--base-root 顺序合成和重开验证。
  • 新增 TypeTree UI 文本提取与回写工具,覆盖组件 m_text、UI 标签字段和 Unity Localization StringTable。
  • 新增 Addressables binary catalog CRC 工具:从 AssetBundle 内部名称唯一定位记录,只生成外部 catalog 候选并限制为四字节 CRC 修改。
  • 新增 TMP 使用链追踪工具,从可见组件追踪 FontAsset、Material、External FileID、CAB、bundle 与 PathID。
  • 新增静态 TMP FontAsset 候选生成器,成套处理字符表、glyph 表、材质和 SDF atlas,并验证真实翻译字符覆盖。
  • 扩展 TMP 字体检查器,报告动态/静态模式、已有字符表、源 Font PPtr、字体身份冲突和“仅替换源字体”的风险。
  • 更新技能说明、运行时适配器、字体规范、AiNiee 衔接说明与 agents/openai.yaml。

复盘根因

此前工作流存在三类主要盲区:

  1. 只覆盖剧情容器,遗漏设置页、组件 UI 和 Localization StringTable。
  2. 重打包 Addressables bundle 后没有把 bundle 与 catalog CRC 作为同一原子 canary,可能导致运行时黑屏。
  3. 字体修复曾按名称猜测主字体,并只替换动态 TMP 的源字体;旧 glyph index 与新字体冲突时,正确 Unicode 会稳定显示成另一个合法汉字。

安全边界

  • 必须从出现问题的可见组件反查实际 FontAsset,不按文件名或字体名猜测。
  • 动态 TMP 已有 character/glyph 表时禁止只替换源 TTF;静态替换必须成套替换表、材质和 atlas。
  • “正确文本显示成另一合法汉字”优先判定为 glyph-index 冲突,先核对 CSV 与 Unicode,不归因于翻译。
  • Addressables bundle 与 catalog 必须原子应用和回滚;CRC 工具不猜测 catalog.hash,不修改 bundleSize。
  • DMSL 超出固定字节预算时整批拒绝,不静默截断。
  • 所有二进制候选默认必须输出到游戏目录之外。

用户影响

技能可以更完整地覆盖剧情、设置页和本地化表文本,并为 Addressables 黑屏与 TMP 错字映射提供可复用、可审计的诊断和修复路径。现有 AiNiee 翻译流程不变。

验证

  • quick_validate.py 通过。
  • 8 个新增或修改的 CLI 均通过 py_compile 与 --help。
  • 7 个新 CLI 的缺少必需参数失败路径均正确拒绝。
  • 仓库内 14 个文件与已完成回归验证的 staging 文件逐项 SHA-256 一致。
  • 已在原始备份样本上完成 DMSL/UI 真实提取、翻译 dry-run、catalog 四字节差异、TMP 使用链与字符覆盖验证。
  • 无结论泄漏的前向测试能够独立定位 Addressables 完整性黑屏与 TMP glyph-index 错映射。
  • git diff --cached --check 通过;未包含游戏二进制、字体、项目报告、机器绝对路径或临时测试目录。

@timeance
timeance marked this pull request as ready for review July 18, 2026 07:06
@timeance
timeance merged commit b6d3f14 into main Jul 18, 2026
4 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b8303c8168

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +53 to +55
.replace("\r\n", "\n")
.replace("\r", "\n")
.replace("\n", "\\n")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve CR bytes in DMSL source rows

When a DMSL operand contains \r or CRLF line breaks, the extractor writes the source CSV with those bytes normalized to \n, but the writeback path later unflattens that cell as LF-only and compares it to original_utf8_sha256. That makes the freshly generated source CSV fail its own manifest validation for any row with CR/CRLF text, so those extracted rows cannot be dry-run or preserved successfully.

Useful? React with 👍 / 👎.

raise SystemExit(f"input file not found: {source}")
if not game_root.is_dir():
raise SystemExit(f"game root not found: {game_root}")
if out == target or inside(out, game_root) or inside(report_path, game_root):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject output paths that overwrite donor assets

If the donor bundle is outside the game root, --out can be set to the same path as --donor and --force will allow the build to proceed; the final os.replace(temp, out) then overwrites the donor input even though it is supposed to be a template for the candidate. This check should reject the donor path as well as the target path before any output conflict handling.

Useful? React with 👍 / 👎.

@timeance
timeance deleted the agent/harden-unity-text-locator branch July 23, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant