赛尔号 Unity 资源转 Codex pet 的构建流程和示例。
当前仓库包含:
skills/unity-codex-pet:Unity 资源提取、动作预览、Codex pet 打包的 Codex skill。example/puni:谱尼示例 pet,可直接复制到~/.codex/pets/puni使用。example/puni/actions:从 UnityAnimationClip导出的动作 WebP 预览。
示例谱尼 pet 使用 Unity pfa_300 资源构建,输出为 Codex pet 固定布局:
- atlas:
1536 x 1872 - cell:
192 x 208 - layout:
8列 x9行 - animation:
42帧,约12fps - encoding:lossless animated WebP
mkdir -p ~/.codex/pets/puni
cp example/puni/pet.json example/puni/spritesheet.webp ~/.codex/pets/puni/验证:
webpmux -info ~/.codex/pets/puni/spritesheet.webp
cat ~/.codex/pets/puni/pet.json期望结果:
Canvas size: 1536 x 1872Number of frames: 42- frame duration 为
83/84ms Loop Count : 0
mkdir -p ~/.codex/skills/unity-codex-pet
rsync -a --delete skills/unity-codex-pet/ ~/.codex/skills/unity-codex-pet/之后可以在 Codex 中使用 unity-codex-pet skill 处理 Unity pet 资源。
依赖:
uvcwebpwebpmux
Python 依赖通过 uv 临时注入:
uv run --with UnityPy --with Pillow python skills/unity-codex-pet/scripts/unity_pet_pipeline.py --help如果拿到的是 .rar,先自行解压。脚本可直接处理 zip 或已解压目录。
uv run --with UnityPy --with Pillow python skills/unity-codex-pet/scripts/unity_pet_pipeline.py \
scan \
--source /path/to/PC \
--out work/puni在扫描结果里找到目标 bundle。本示例使用:
/path/to/PC/pfa_300
uv run --with UnityPy --with Pillow python skills/unity-codex-pet/scripts/unity_pet_pipeline.py \
export \
--bundle /path/to/PC/pfa_300 \
--out work/puni/actions导出结果包括:
300_idle.webp300_sa.webp300_cp.webp300_hited.webp300_attack.webpmetadata.jsoncontact-sheet-first-frame.png
导出逻辑使用 Unity AnimationClip.m_ClipBindingConstant.pptrCurveMapping 读取 SpriteRenderer 帧序列,不靠文件名猜顺序。
cp example/puni/mapping.json work/puni/actions/mapping.json当前映射:
| Codex state | Unity action |
|---|---|
idle |
300_idle |
waiting |
300_idle |
running |
300_sa |
running-right |
300_sa |
running-left |
300_sa |
waving |
300_cp |
jumping |
300_cp |
failed |
300_hited |
review |
300_cp |
uv run --with UnityPy --with Pillow python skills/unity-codex-pet/scripts/unity_pet_pipeline.py \
build-pet \
--actions work/puni/actions \
--mapping work/puni/actions/mapping.json \
--out work/puni/pet检查 QA:
open work/puni/pet/qa/contact-sheet-first-frame.png
open work/puni/pet/qa/contact-sheet-sampled-frames.pnguv run --with UnityPy --with Pillow python skills/unity-codex-pet/scripts/unity_pet_pipeline.py \
install \
--built work/puni/pet \
--pet-dir ~/.codex/pets/puni资源来自 bilibili@青屿抱抱您 分享的赛尔号资源包。
通过网盘分享的文件:SeerGo
链接: https://pan.baidu.com/s/1H5bgd-MvOMAX4KK-rd9ShA?pwd=iwpv
提取码: iwpv
中国移动云盘分享文件:“重启号”
链接: https://yun.139.com/shareweb/#/w/i/2sUfDCxL13L6t
本仓库不包含原始 Unity 资源包,只包含从资源包构建出的示例 Codex pet、动作预览和构建脚本。
原始高清 SWF 方案
如果需要页游原始高清 SWF 资源,也可以走 SWF 解析路线。赛尔号页游战斗宠物 SWF 常见地址格式类似:
http://seer.61.com/resource/fightResource/pet/swf/300.swf
其中 300.swf 可替换为目标精灵 ID 对应的 SWF 文件。
解析工具推荐使用 JPEXS Free Flash Decompiler:
https://github.com/jindrapetrik/jpexs-decompiler
在线预览 SWF 可使用 Ruffle demo:
https://ruffle.rs/demo/
Ruffle 适合快速确认 SWF 是否能正常播放、动作是否存在、帧率大致是否正确;正式导出和打包仍建议以 JPEXS 解析出的 timeline、子 Sprite 和帧率为准。
基本流程:
- 下载目标
*.swf。 - 用 JPEXS 打开 SWF,检查
DefineSprite/ timeline / ActionScript 里实际调用的动作。 - 导出 Sprite、Shape、Image 或逐帧 PNG/WebP 序列。
- 根据 SWF 的帧率和动作时间轴重新合成为 animated WebP。
- 再按 Codex pet 的
1536 x 1872、8 x 9固定布局打包。
注意:SWF 方案不要只靠截图录屏抽帧。正确做法是从 JPEXS 解析出的 timeline、子 Sprite 和帧率恢复动作,否则很容易出现缺帧、速度错误、动作缩放或画布错位。
skills/unity-codex-pet/
SKILL.md
agents/openai.yaml
scripts/unity_pet_pipeline.py
example/puni/
pet.json
spritesheet.webp
source-note.json
mapping.json
actions/
qa/