Skip to content

feat: batch of capability tools (asset import, references, mesh, physics, particle, material, project/undo/component/lighting/timeline/dialog)#35

Open
dehuaichendragonplus wants to merge 1 commit into
FunplayAI:mainfrom
dehuaichendragonplus:feat/capability-tools-batch
Open

feat: batch of capability tools (asset import, references, mesh, physics, particle, material, project/undo/component/lighting/timeline/dialog)#35
dehuaichendragonplus wants to merge 1 commit into
FunplayAI:mainfrom
dehuaichendragonplus:feat/capability-tools-batch

Conversation

@dehuaichendragonplus

Copy link
Copy Markdown
Contributor

Why

Driving Unity through this MCP, an agent repeatedly hits operations with no dedicated tool and has to hand-roll execute_code for them: reading/writing importer settings, asking "what references this asset", inspecting a mesh, casting a physics ray, reading material shader props, undo, etc. These are common, fiddly, and error-prone to re-derive each time. This PR adds dedicated, structured-output tools for that gap (backlog "capability" set), so the common cases are one reliable call.

Approach

12 new self-contained [ToolProvider] files under Editor/Tools/Builtins/, following the existing conventions:

  • Each tool returns object via Response.Success(msg, data) / Response.Error(CODE, data) — the same {success, ...} envelope the rest of the surface uses.
  • Scene targets resolve through ObjectsHelper (name / hierarchy path / instance id, inactive included); assets through AssetDatabase.
  • Read tools are [ReadOnlyTool]; mutating tools are [SceneEditingTool] and use Undo where the operation is undoable.
  • Optional-package types (Timeline) are accessed purely by reflection, so the package compiles without a com.unity.timeline asmdef reference and degrades to a clear error when absent.

New tools

Provider Tools
AssetImport get_asset_import_settings, set_asset_import_settings
References find_references, find_broken_references
Mesh get_mesh_info
Physics physics_raycast, physics_overlap, physics2d_overlap_point
Particle particle_control
Material get_material_properties, set_material_property
ProjectSettings get_project_settings, get_editor_pref
Undo undo, redo, get_undo_state
ComponentBatch copy_component, paste_component_values, add_component_to_many
Lighting get_lighting_settings, set_lighting_settings, bake_lightmaps
Timeline director_evaluate (reflection-based)
Dialog list_open_dialogs, dismiss_dialog

Test results

Verified in a Unity 6000.3.13f1 project (embedded package, compiles with zero errors). Every tool was exercised and returns a proper structured envelope; highlights:

  • get_asset_import_settings reads full Texture importer fields; set_... round-trips and reads applied values back.
  • find_references reverse-scanned 19,085 project assets and correctly found the referencing asset; per-direction truncated flags reported.
  • get_mesh_info → 24 verts / 12 tris / UV channels on a cube; physics_raycast/overlap hit the expected collider; particle_control simulate froze a VFX at a fixed time; director_evaluate returns a clean PLAYABLE_DIRECTOR_NOT_FOUND when no director is bound.
  • copy_component/paste_component_values/add_component_to_many per-target results verified; undo/redo round-trip verified.
  • dismiss_dialog refuses to close docked panels (Inspector/Console) and only acts on floating/utility windows.

The whole set then went through an adversarial multi-angle code review; 15 findings were fixed and the affected tools re-tested through the live MCP interface (malformed args now return INVALID_PARAM instead of silent wrong writes; oversized captures spill to file; particle_control clamps simulate time; physics queries SyncTransforms first; lighting validates enum/color; component paste-as-new is undo-tracked; etc.).

Compatibility

  • All new tools sit at the tool-call layer over the existing MCP protocol — no wire-protocol, initialize, or transport change → compatible with every MCP client (Claude Code, Cursor, LM Studio, VS Code, Trae, Kiro, Codex).
  • All new files; no existing file is modified, so there is no interaction with other in-flight PRs.
  • Timeline support is reflection-only (no new package dependency); every other tool uses core engine/editor APIs verified present and non-obsolete on 6000.3.13f1.

Checklist

  • Tested in a clean Unity 2022.3+ project (Unity 6000.3.13f1)
  • Verified Funplay > MCP Server opens and starts correctly
  • Did not commit local junk such as .idea/ or .DS_Store
  • Updated CHANGELOG.md

…ics, particle, material, project/undo/component/lighting/timeline/dialog)

12 new self-contained [ToolProvider] files under Editor/Tools/Builtins/, each returning the
standard {success,...}/{success:false,code} envelope and resolving scene targets through
ObjectsHelper. Adds tools for operations an agent otherwise hand-rolls via execute_code:
get/set_asset_import_settings, find_references/find_broken_references, get_mesh_info,
physics_raycast/overlap/physics2d_overlap_point, particle_control, get/set_material_property,
get_project_settings/get_editor_pref, undo/redo/get_undo_state,
copy_component/paste_component_values/add_component_to_many, get/set_lighting_settings/bake_lightmaps,
director_evaluate (reflection-based, no com.unity.timeline dep), list_open_dialogs/dismiss_dialog.

All new files (no existing file touched). Compiles clean on Unity 6000.3.13f1; every tool exercised
and returns a proper envelope; then hardened via an adversarial audit (15 issues fixed and re-tested
through the live MCP interface): malformed args -> INVALID_PARAM, particle simulate time clamped,
physics SyncTransforms first, lighting enum/color validation, paste-as-new undo-tracked,
dismiss_dialog refuses docked panels, oversized multiview spills to file.
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