Repository navigation
v0.3.86 — Build and wire UI prefabs with MCP tools alone; Play Mode keeps running in the background
Why this matters
Building a new UI feature with an AI agent (generated art, new prefabs, wiring
the fields that connect them, then checking the flow in Play Mode) still needed
a hand-written editor script in the project. The MCP could not create a prefab,
and unity_prefab_mutate refused to point a field such as Button _openButton
at another object, so every new view needed project code that called
SerializedObject directly. Play Mode could also sit at 0 frames per second
while the Unity editor was in the background. The warning told the developer to
focus the editor, but never named the existing setting that fixes it.
What changed
- New tool
unity_prefab_create. It creates a prefab asset from a list of
typed operations: an empty root (a RectTransform by default), children,
components (any concrete type, such asImage,Button,TextMeshProUGUI,
layout groups or your own scripts), layout and field values. It validates the
result before saving and only writes withapprove=trueand
previewOnly=false. An existing asset is refused unlessoverwrite=true.
The prefab is built in a preview scene, andopen_scene_dirtiedreports if an
open scene was marked dirty anyway. - Component and GameObject references are writable. In
unity_prefab_mutateandunity_prefab_create, a field can point at an
object inside the same prefab (Root/ChildorRoot/Child#ComponentType,
including objects created earlier in the same call) or at a prefab asset path
or GUID. The target must fit the field's declared type: a mismatch fails as
prefab_mutation_reference_type_mismatch, and the whole call is rolled back.
Identity fields such asm_Scriptandm_GameObjectstay refused, so a
component still cannot be swapped for another type. - Arrays, placement and layout.
field.Array.data[i]appends wheniequals
the current size, andfield.Array.sizesets the size. A write past the end
fails asprefab_mutation_array_index_out_of_rangeinstead of padding.
The new opcreate_childadds an empty child.siblingIndexand
afterSiblingplace new children and nested prefab instances.
set_rect_transformalso acceptsoffsetMin,offsetMax,localScaleand
stretch(fill the parent). add_componentreports a refused component. When Unity refused to attach
a component (for example a script from an editor-only assembly), the change
used to sayappliedand the next step failed with an unrelated error. It now
fails asprefab_mutation_component_add_failed.- Background Play Mode from a tool call.
unity_playmode_setaccepts
backgroundExecution: "managed", with any action or with the new
action: "configure". It savesbackground_execution_enabledin the project's
bridge config, keeping the other settings in that file. Unity's
runInBackgroundproject setting is now changed only just before Play Mode
starts and restored once the editor is back in Edit Mode. Before, it stayed
changed for the whole editor session. When Play Mode is throttled because the
editor is unfocused and this is off, the remediation is now
enable_background_execution_with_unity_playmode_set_background_execution_managed_or_focus_the_unity_editor. - Project actions send their declared constants. A project action catalog
entry can declare a payload field asstring_const_<value>, for example
operation: string_const_reset_state. The hook used to receive no value
unless the caller repeated it, so it could quietly run its default branch while
the action reported success. The value is now always sent, and a different
caller value is refused asproject_action_payload_const_conflict. - Mutation proof for project hooks in one line.
XUUnityLightMcpMutationDelta.FromWrittenAssets(written, created, prefsKeys)
anddelta.AttachTo(payloadJson)produce thexuunity.mutation-delta.v1
record thatunity_project_action_invokeneeds to report a mutating action as
verified, instead ofpassed_unverified_mutation_delta. - UI queries match what a click accepts. A button whose own image is fully
transparent but has a visible child now matchesrequireVisible, the same
ruleunity_ui_clickuses. Such nodes reportvisible_via_descendantand
visible_descendant_path.unity_ui_queryreportsinactive_subtrees_skipped
when inactive objects were not searched. - Tests can start from dirty scenes.
unity_tests_run_editmodeand
unity_tests_run_playmodeacceptallowDirtySceneDiscard. Saved scenes with
unsaved changes are reloaded from disk and untitled ones are dropped before the
run. Without it, thedirty_scenerefusal now lists each scene, explains that
editor startup, a Play Mode cycle or an editor script can mark a scene dirty,
and names the flag.
What this gives developers
- A new popup or list item can be built, wired and validated with MCP tools
alone, without adding an editor script to the project. - A wrong wiring target fails before anything is saved, with the field and the
expected type in the error. - Play Mode checks keep running while you work in another window, and the
project'srunInBackgroundsetting is no longer left changed in
ProjectSettings.asset. - A project action that forgets a required constant can no longer pass while
doing something else.
Validation
- Host Python suite: 1280 tests passed, 14 platform skips.
- Package self-test lane on Unity
6000.0.58f2in a clean project with uGUI
and TextMeshPro, using the local package source: EditMode core 209/209,
TextMeshPro 6/6, uGUI 57/57; PlayMode uGUI 19 passed with 6 skipped, PlayMode
core 6/6. - The new tools were driven through the MCP server against a live editor:
unity_prefab_createpreview, write, and refusal of an existing asset; a
wrong-type reference rolled back;unity_prefab_validatepassed on the
result;unity_playmode_setswitched background execution both ways while
keeping the other bridge config keys. - Background execution was measured live with the editor unfocused on
6000.0.58f2: about 3000 frames per ~1 s liveness sample when managed and
about 14 when project-owned.ProjectSettings.assetkept
runInBackground: 0after Play Mode cycles and an editor quit. - Public site checks: 42 passed.
Known limitations
Unity Package CIremains waived because its runners have no Unity license;
the local licensed lane above is the package evidence.- Live runs were on macOS with Unity
6000.0.58f2only. Other Unity versions
and Windows/Linux are covered by host tests and fixtures, not a live run. - The
allowDirtySceneDiscardpath of the test tools is covered by host tests
only; it was not run against a dirty scene live. - Catalog payload tokens other than
string_const_(*_default_*,
required_*) remain descriptive; the hook still owns those defaults.
Install with the Git UPM URL:
https://github.com/FoxsterDev/xuunity-mcp.git?path=/packages/com.xuunity.light-mcp#v0.3.86