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
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Driving Unity through this MCP, an agent repeatedly hits operations with no dedicated tool and has to hand-roll
execute_codefor 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 underEditor/Tools/Builtins/, following the existing conventions:objectviaResponse.Success(msg, data)/Response.Error(CODE, data)— the same{success, ...}envelope the rest of the surface uses.ObjectsHelper(name / hierarchy path / instance id, inactive included); assets throughAssetDatabase.[ReadOnlyTool]; mutating tools are[SceneEditingTool]and useUndowhere the operation is undoable.com.unity.timelineasmdef reference and degrades to a clear error when absent.New tools
get_asset_import_settings,set_asset_import_settingsfind_references,find_broken_referencesget_mesh_infophysics_raycast,physics_overlap,physics2d_overlap_pointparticle_controlget_material_properties,set_material_propertyget_project_settings,get_editor_prefundo,redo,get_undo_statecopy_component,paste_component_values,add_component_to_manyget_lighting_settings,set_lighting_settings,bake_lightmapsdirector_evaluate(reflection-based)list_open_dialogs,dismiss_dialogTest 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_settingsreads full Texture importer fields;set_...round-trips and reads applied values back.find_referencesreverse-scanned 19,085 project assets and correctly found the referencing asset; per-directiontruncatedflags reported.get_mesh_info→ 24 verts / 12 tris / UV channels on a cube;physics_raycast/overlaphit the expected collider;particle_control simulatefroze a VFX at a fixed time;director_evaluatereturns a cleanPLAYABLE_DIRECTOR_NOT_FOUNDwhen no director is bound.copy_component/paste_component_values/add_component_to_manyper-target results verified;undo/redoround-trip verified.dismiss_dialogrefuses 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_PARAMinstead of silent wrong writes; oversized captures spill to file;particle_controlclamps simulate time; physics queriesSyncTransformsfirst; lighting validates enum/color; component paste-as-new is undo-tracked; etc.).Compatibility
initialize, or transport change → compatible with every MCP client (Claude Code, Cursor, LM Studio, VS Code, Trae, Kiro, Codex).Checklist
Funplay > MCP Serveropens and starts correctly.idea/or.DS_StoreCHANGELOG.md