Skip to content

phainia/seer-codex-pet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

谱尼 idle 动画

seer-codex-pet

赛尔号 Unity 资源转 Codex pet 的构建流程和示例。

当前仓库包含:

  • skills/unity-codex-pet:Unity 资源提取、动作预览、Codex pet 打包的 Codex skill。
  • example/puni:谱尼示例 pet,可直接复制到 ~/.codex/pets/puni 使用。
  • example/puni/actions:从 Unity AnimationClip 导出的动作 WebP 预览。

示例谱尼 pet 使用 Unity pfa_300 资源构建,输出为 Codex pet 固定布局:

  • atlas:1536 x 1872
  • cell:192 x 208
  • layout:8 列 x 9
  • animation:42 帧,约 12fps
  • encoding:lossless animated WebP

puni contact sheet

直接安装示例 pet

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 1872
  • Number of frames: 42
  • frame duration 为 83/84ms
  • Loop Count : 0

安装 skill

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 资源。

从 Unity 资源重建

依赖:

  • uv
  • cwebp
  • webpmux

Python 依赖通过 uv 临时注入:

uv run --with UnityPy --with Pillow python skills/unity-codex-pet/scripts/unity_pet_pipeline.py --help

如果拿到的是 .rar,先自行解压。脚本可直接处理 zip 或已解压目录。

1. 扫描资源

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

2. 导出 Unity 动作 WebP

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.webp
  • 300_sa.webp
  • 300_cp.webp
  • 300_hited.webp
  • 300_attack.webp
  • metadata.json
  • contact-sheet-first-frame.png

导出逻辑使用 Unity AnimationClip.m_ClipBindingConstant.pptrCurveMapping 读取 SpriteRenderer 帧序列,不靠文件名猜顺序。

3. 使用示例映射

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

4. 构建 pet

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.png

5. 安装构建结果

uv 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 和帧率为准。

基本流程:

  1. 下载目标 *.swf
  2. 用 JPEXS 打开 SWF,检查 DefineSprite / timeline / ActionScript 里实际调用的动作。
  3. 导出 Sprite、Shape、Image 或逐帧 PNG/WebP 序列。
  4. 根据 SWF 的帧率和动作时间轴重新合成为 animated WebP。
  5. 再按 Codex pet 的 1536 x 18728 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/

About

赛尔号 codex pet

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages