Skip to content

v0.3.86 — Build and wire UI prefabs with MCP tools alone; Play Mode keeps running in the background

Choose a tag to compare

@FoxsterDev FoxsterDev released this 04 Nov 20:11
· 75 commits to main since this release

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 as Image, Button, TextMeshProUGUI,
    layout groups or your own scripts), layout and field values. It validates the
    result before saving and only writes with approve=true and
    previewOnly=false. An existing asset is refused unless overwrite=true.
    The prefab is built in a preview scene, and open_scene_dirtied reports if an
    open scene was marked dirty anyway.
  • Component and GameObject references are writable. In
    unity_prefab_mutate and unity_prefab_create, a field can point at an
    object inside the same prefab (Root/Child or Root/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 as m_Script and m_GameObject stay refused, so a
    component still cannot be swapped for another type.
  • Arrays, placement and layout. field.Array.data[i] appends when i equals
    the current size, and field.Array.size sets the size. A write past the end
    fails as prefab_mutation_array_index_out_of_range instead of padding.
    The new op create_child adds an empty child. siblingIndex and
    afterSibling place new children and nested prefab instances.
    set_rect_transform also accepts offsetMin, offsetMax, localScale and
    stretch (fill the parent).
  • add_component reports a refused component. When Unity refused to attach
    a component (for example a script from an editor-only assembly), the change
    used to say applied and the next step failed with an unrelated error. It now
    fails as prefab_mutation_component_add_failed.
  • Background Play Mode from a tool call. unity_playmode_set accepts
    backgroundExecution: "managed", with any action or with the new
    action: "configure". It saves background_execution_enabled in the project's
    bridge config, keeping the other settings in that file. Unity's
    runInBackground project 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 as string_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 as project_action_payload_const_conflict.
  • Mutation proof for project hooks in one line.
    XUUnityLightMcpMutationDelta.FromWrittenAssets(written, created, prefsKeys)
    and delta.AttachTo(payloadJson) produce the xuunity.mutation-delta.v1
    record that unity_project_action_invoke needs to report a mutating action as
    verified, instead of passed_unverified_mutation_delta.
  • UI queries match what a click accepts. A button whose own image is fully
    transparent but has a visible child now matches requireVisible, the same
    rule unity_ui_click uses. Such nodes report visible_via_descendant and
    visible_descendant_path. unity_ui_query reports inactive_subtrees_skipped
    when inactive objects were not searched.
  • Tests can start from dirty scenes. unity_tests_run_editmode and
    unity_tests_run_playmode accept allowDirtySceneDiscard. Saved scenes with
    unsaved changes are reloaded from disk and untitled ones are dropped before the
    run. Without it, the dirty_scene refusal 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's runInBackground setting 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.58f2 in 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_create preview, write, and refusal of an existing asset; a
    wrong-type reference rolled back; unity_prefab_validate passed on the
    result; unity_playmode_set switched 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.asset kept
    runInBackground: 0 after Play Mode cycles and an editor quit.
  • Public site checks: 42 passed.

Known limitations

  • Unity Package CI remains 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.58f2 only. Other Unity versions
    and Windows/Linux are covered by host tests and fixtures, not a live run.
  • The allowDirtySceneDiscard path 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