Skip to content

feat(asset-gen): add animation_type rig mode to import_model_file#1262

Merged
Scriptwonder merged 3 commits into
CoplayDev:betafrom
Scriptwonder:feat/import-model-file-animation-type
Jul 12, 2026
Merged

feat(asset-gen): add animation_type rig mode to import_model_file#1262
Scriptwonder merged 3 commits into
CoplayDev:betafrom
Scriptwonder:feat/import-model-file-animation-type

Conversation

@Scriptwonder

@Scriptwonder Scriptwonder commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Problem

A rigged/animated FBX imported through import_model_file always arrives with zero AnimationClips: the import pipeline hard-codes ModelImporterAnimationType.None, so Unity strips the rig and clips silently. Agents (and humans) conclude the export was broken when it wasn't.

Change

Thread an optional animation_type param — none | generic | humanoid | legacy — through all three layers:

  • C#: AssetGenJob.AnimationType + ModelImportPipeline.ParseAnimationType() (internal, unit-tested); ImportModelFile reads animationType.
  • Python MCP tool: animation_type as a Literal param on import_model_file, forwarded camelCase; tool description documents the FBX/OBJ-only semantics.
  • CLI: --animation-type with a matching click.Choice.

The default stays None, so existing imports are byte-for-byte unchanged. glTF/GLB ignores the knob — glTFast imports animation itself.

Also folds tested Blender-handoff findings into the blender-to-unity skill: GLB-vs-FBX format-fidelity guidance with a new references/bridge-fidelity.md matrix (force-added; .claude is gitignored), FBX emission-restoration steps, and the animation_type usage. Syncs Server/uv.lock with the 10.0.0 version already in pyproject.toml on beta.

Testing

  • Python: full suite green locally — 1314 passed, 3 skipped — including new routing (animationType reaches the wire camelCase, absent when unset) and CLI tests.
  • Unity: headless EditMode run on 2021.3.45f2 (the CI floor): 1105 tests, 0 failed; the 9 new ParseAnimationType TestCases (case/whitespace-insensitive mapping, human alias, safe None fallback for null/empty/nonsense) all pass.
  • Manually exercised via the Blender→Unity handoff: a rigged FBX imported with animation_type="generic" surfaces its clips; without it, mesh-only import as before.

https://claude.ai/code/session_01Cya1SZmg7CJgJS61nhjLH4

Summary by CodeRabbit

  • New Features
    • Added an --animation-type option for model imports (none, generic, humanoid, legacy) and wired it through to the Unity importer for FBX/OBJ to select rig/animation import behavior.
  • Documentation
    • Expanded Blender→Unity transfer guidance, including GLB vs FBX nuances, plus a new empirical fidelity matrix and an FBX emission recovery workflow.
  • Tests
    • Added/updated routing and importer parsing tests to verify animationType payload mapping and robust case/whitespace handling.

A rigged/animated FBX imported through import_model_file always arrived
with zero AnimationClips because the import pipeline hard-coded
ModelImporterAnimationType.None. Thread an optional animation_type param
(none|generic|humanoid|legacy) through the MCP tool, the CLI command, and
the C# pipeline so callers can surface a model's clips; the default stays
None, so existing imports are unchanged. glTF/GLB ignores the knob
(glTFast imports animation itself).

Also fold the tested Blender-handoff findings into the blender-to-unity
skill: GLB-vs-FBX fidelity guidance (with the new
references/bridge-fidelity.md matrix, force-added since .claude is
gitignored), FBX emission restoration steps, and the animation_type knob.
Sync uv.lock with the pyproject 10.0.0 version already on beta.

Claude-Session: https://claude.ai/code/session_01Cya1SZmg7CJgJS61nhjLH4
Copilot AI review requested due to automatic review settings July 12, 2026 06:58
@Scriptwonder Scriptwonder added safe-to-test Triggers CI checks full-matrix Enable full-matrix CI test labels Jul 12, 2026
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4dab7401-ab64-4af3-9291-44bc8626fa9c

📥 Commits

Reviewing files that changed from the base of the PR and between 283e393 and 7ffc830.

📒 Files selected for processing (2)
  • Server/src/services/tools/import_model_file.py
  • website/docs/reference/tools/asset_gen/import_model_file.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • Server/src/services/tools/import_model_file.py
  • website/docs/reference/tools/asset_gen/import_model_file.md

📝 Walkthrough

Walkthrough

The change adds FBX/OBJ animation-type selection to the model import CLI and tool, propagates it through Unity job state and importer settings, adds routing and parsing tests, and expands Blender–Unity fidelity documentation with GLB/FBX guidance and FBX emission recovery steps.

Changes

Model import fidelity

Layer / File(s) Summary
Animation option contract and routing
Server/src/services/tools/import_model_file.py, Server/src/cli/commands/asset_gen.py, Server/tests/test_asset_gen_import_file.py, website/docs/reference/tools/asset_gen/import_model_file.md
CLI and tool inputs accept none, generic, humanoid, and legacy, forward the selected value as animationType, and document FBX/OBJ-only behavior with routing coverage.
Unity animation import application
MCPForUnity/Editor/Services/AssetGen/..., MCPForUnity/Editor/Tools/AssetGen/ImportModelFile.cs, TestProjects/UnityMCPTests/...
Unity persists the requested animation type, maps normalized values to importer modes, and tests null, unknown, casing, and whitespace inputs.
Blender–Unity fidelity guidance
.claude/skills/blender-to-unity/SKILL.md, .claude/skills/blender-to-unity/references/bridge-fidelity.md
Documentation adds tool-dispatch guidance, GLB/FBX selection rules, scene and animation caveats, FBX emission recovery steps, and format-fidelity results.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant import_model_file
  participant ImportModelFile
  participant ModelImportPipeline
  CLI->>import_model_file: provide animation_type
  import_model_file->>ImportModelFile: send animationType
  ImportModelFile->>ModelImportPipeline: pass AssetGenJob.AnimationType
  ModelImportPipeline->>ModelImportPipeline: apply parsed importer animation type
Loading
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is informative but misses most required template sections, including Type of Change, Changes Made, Compatibility, and checklists. Rewrite the PR description using the repository template and fill in the missing sections, especially Type of Change, Changes Made, Compatibility, Testing, and Documentation Updates.
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding animation_type support to import_model_file.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds an optional animation_type parameter to the import_model_file pipeline so rigged/animated FBX imports can surface AnimationClips by configuring Unity’s ModelImporter.animationType, while keeping the default behavior unchanged (None).

Changes:

  • Thread animation_type from Python tool + CLI down into the Unity C# import pipeline (AssetGenJob.AnimationTypeModelImportPipeline.ParseAnimationType()ModelImporter.animationType).
  • Add unit tests in both Unity (rig mode parsing) and Python (wire payload/CLI flag routing).
  • Expand Blender→Unity handoff skill docs with format-fidelity guidance and a new reference matrix.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/ModelImportPipelineTests.cs Adds EditMode coverage for ParseAnimationType mappings.
MCPForUnity/Editor/Services/AssetGen/Import/ModelImportPipeline.cs Applies parsed animation type to ModelImporter and introduces ParseAnimationType.
MCPForUnity/Editor/Tools/AssetGen/ImportModelFile.cs Reads animationType param into the AssetGenJob used for import.
MCPForUnity/Editor/Services/AssetGen/AssetGenJobManager.cs Extends AssetGenJob with AnimationType field.
Server/src/services/tools/import_model_file.py Adds animation_type tool param and forwards animationType camelCase to Unity.
Server/src/cli/commands/asset_gen.py Adds --animation-type flag and forwards animationType in the CLI payload.
Server/tests/test_asset_gen_import_file.py Updates allowed payload keys and adds routing/CLI tests for animationType.
Server/uv.lock Syncs locked package version to 10.0.0.
.claude/skills/blender-to-unity/SKILL.md Updates skill guidance for GLB-vs-FBX fidelity and documents animation_type usage.
.claude/skills/blender-to-unity/references/bridge-fidelity.md Adds a tested format-fidelity matrix for the Blender→Unity bridge.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


/// <summary>
/// Map the caller's rig mode to a <see cref="ModelImporterAnimationType"/>. Defaults to
/// <c>None</c> (no rig) when unset — pass "generic"/"humanoid" to surface a rigged FBX/OBJ's
"name, output_folder (under Assets/), target_size. Returns { asset_path, asset_guid }.\n\n"
"name, output_folder (under Assets/), target_size, animation_type. "
"Returns { asset_path, asset_guid }.\n\n"
"animation_type (FBX/OBJ only): pass 'generic' or 'humanoid' for a rigged/animated mesh so "
Comment on lines +49 to +50
"FBX/OBJ only: rig/animation import mode. 'generic' or 'humanoid' surface the model's "
"AnimationClips; 'none' (default) imports no rig. Ignored for glTF/GLB.",
Comment thread Server/src/cli/commands/asset_gen.py Outdated
@click.option("--target-size", default=None, type=float, help="Normalize largest dimension (meters).")
@click.option("--animation-type", "animation_type", default=None,
type=click.Choice(["none", "generic", "humanoid", "legacy"]),
help="FBX/OBJ rig mode: generic/humanoid surface animation clips (glTF ignores this).")

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 8

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.claude/skills/blender-to-unity/references/bridge-fidelity.md:
- Around line 62-65: Update the GLB export recipes around the rig/morph guidance
and the generic command to separate static geometry from rigged or shape-key
assets: use export_apply=True only for static geometry, and provide a distinct
rig/morph command using export_apply=False while preserving skin and morph
export settings.
- Around line 90-92: Update the export_animations=True guidance in the GLB
export options to state that only eligible active or stashed actions are
exported through the object’s active action or NLA tracks, rather than all
actions; mention the required Action/NLA setup while leaving the export_morph
guidance unchanged.

In @.claude/skills/blender-to-unity/SKILL.md:
- Around line 106-109: Update the GLB export example in the glTF/glTFast
guidance to include use_active_scene=True, preserving the existing export
behavior while ensuring the currently active Blender scene is exported.
- Around line 44-46: Update the rigged/animated FBX guidance to document all
supported animation_type values: none, generic, humanoid, and legacy. Clarify
that none intentionally imports the mesh without animation clips, while generic,
humanoid, and legacy select the corresponding animation import modes; keep the
GLB behavior unchanged.
- Around line 104-110: Update the “Materials & emission” guidance to state that
FBX preserves vertex-color data, while default URP Lit does not display it
without a vertex-color-reading shader. Keep the separate limitation that FBX
drops emission and node-based color, and retain the glTF/GLB and Step 5
recommendations.
- Around line 25-30: Update the format-selection guidance near the GLB/FBX
bullets to remove multi-material zones as an independent GLB trigger. Keep GLB
preferred for rigging, animation, PBR, emission, and transparency, while
directing multi-material-only models through the existing FBX fallback because
both formats preserve material slots.
- Around line 40-41: Define a distinct temporary GLB output path variable before
the glTF branch invokes bpy.ops.export_scene.gltf, then pass that variable as
filepath. Keep the existing out path for the other export branch and ensure
out_glb is initialized before use.
- Around line 76-79: Update the Principled BSDF emission handling around p to
support both Blender socket names: prefer “Emission Color” for Blender 4.0+ and
fall back to “Emission” for Blender 3.x, retrieving color and strength from the
selected sockets. Preserve the existing emissive material conversion behavior
across both versions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: da38f393-7bbb-44ef-bd2e-045fc495fa78

📥 Commits

Reviewing files that changed from the base of the PR and between 629d949 and 0eee156.

⛔ Files ignored due to path filters (1)
  • Server/uv.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • .claude/skills/blender-to-unity/SKILL.md
  • .claude/skills/blender-to-unity/references/bridge-fidelity.md
  • MCPForUnity/Editor/Services/AssetGen/AssetGenJobManager.cs
  • MCPForUnity/Editor/Services/AssetGen/Import/ModelImportPipeline.cs
  • MCPForUnity/Editor/Tools/AssetGen/ImportModelFile.cs
  • Server/src/cli/commands/asset_gen.py
  • Server/src/services/tools/import_model_file.py
  • Server/tests/test_asset_gen_import_file.py
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/ModelImportPipelineTests.cs

Comment thread .claude/skills/blender-to-unity/references/bridge-fidelity.md
Comment thread .claude/skills/blender-to-unity/references/bridge-fidelity.md Outdated
Comment thread .claude/skills/blender-to-unity/SKILL.md
Comment thread .claude/skills/blender-to-unity/SKILL.md Outdated
Comment thread .claude/skills/blender-to-unity/SKILL.md Outdated
Comment thread .claude/skills/blender-to-unity/SKILL.md
Comment thread .claude/skills/blender-to-unity/SKILL.md Outdated
Comment thread .claude/skills/blender-to-unity/SKILL.md
…eference

Review responses (CodeRabbit + Copilot):
- Document the 'legacy' animation_type value in the C# XML summary, MCP tool
  description, param help, and CLI help (Copilot x4).
- SKILL.md: drop multi-material zones as a GLB-only trigger (both formats keep
  slots), define out_glb in the glTF branch example, document the full
  animation_type contract, probe both Principled emission socket names
  ('Emission Color' 4.x / 'Emission' 3.x), keep use_active_scene=True in the
  Notes GLB example, and distinguish FBX vertex-color data transfer from URP
  Lit shader display.
- bridge-fidelity.md: make export_apply conditional (static-only; skinned/
  shape-key meshes need False) and document export_animations' active/NLA-
  stashed semantics.

Regenerate website/docs/reference for the updated tool description — fixes the
"Check docs reference is fresh" CI failure ("differs: asset_gen/import_model_file.md").

Claude-Session: https://claude.ai/code/session_01Cya1SZmg7CJgJS61nhjLH4

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@website/docs/reference/tools/asset_gen/import_model_file.md`:
- Around line 17-19: Clarify the source tool documentation to distinguish an
omitted animation_type/animationType, which preserves existing behavior, from
explicitly passing "none", which disables rig import; remove wording that
presents "none" as the API default. Update the source description and regenerate
the auto-generated import_model_file page rather than editing the generated page
directly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1ea4545e-e51b-4bd4-b89b-3a616969d27f

📥 Commits

Reviewing files that changed from the base of the PR and between 0eee156 and 283e393.

📒 Files selected for processing (6)
  • .claude/skills/blender-to-unity/SKILL.md
  • .claude/skills/blender-to-unity/references/bridge-fidelity.md
  • MCPForUnity/Editor/Services/AssetGen/Import/ModelImportPipeline.cs
  • Server/src/cli/commands/asset_gen.py
  • Server/src/services/tools/import_model_file.py
  • website/docs/reference/tools/asset_gen/import_model_file.md
✅ Files skipped from review due to trivial changes (1)
  • .claude/skills/blender-to-unity/references/bridge-fidelity.md
🚧 Files skipped from review as they are similar to previous changes (4)
  • Server/src/cli/commands/asset_gen.py
  • Server/src/services/tools/import_model_file.py
  • MCPForUnity/Editor/Services/AssetGen/Import/ModelImportPipeline.cs
  • .claude/skills/blender-to-unity/SKILL.md

Comment thread website/docs/reference/tools/asset_gen/import_model_file.md Outdated
CodeRabbit follow-up on CoplayDev#1262: the API-level default is omitting the
parameter (nothing crosses the wire); passing 'none' explicitly maps to
the same no-rig import. Say "omitted or 'none'" instead of calling
'none' the default, and regenerate the reference page.

Claude-Session: https://claude.ai/code/session_01Cya1SZmg7CJgJS61nhjLH4
@Scriptwonder Scriptwonder merged commit 628efb6 into CoplayDev:beta Jul 12, 2026
11 checks passed
@Scriptwonder Scriptwonder deleted the feat/import-model-file-animation-type branch July 12, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-matrix Enable full-matrix CI test safe-to-test Triggers CI checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants