Skip to main content

manage_terrain

Auto-generated from the Python tool registry. Do not hand-edit outside <!-- examples:start --><!-- examples:end --> blocks — the generator (tools/generate_docs_reference.py) will overwrite them.

Group: core  ·  Module: services.tools.manage_terrain

Maturity: stable (support status; independent of enabled state, readiness and permissions).

Description​

Inspect and edit existing TerrainData with bounded region/index requests. get_info lists identities/resolutions/layers/prototypes; get_region/set_region use heights, alphamaps, holes (true=surface) or details with exact [y][x] arrays. Regions are at most 32x32 and 4096 scalars. get_trees/set_trees use 1..64 exact existing indices; get_layer/set_layer replace one existing layer slot, preserving count and weights within a 65536-scalar full-alphamap verification budget. Writes require expected_data_guid and the exact scoped expected_revision from the corresponding read. Shared loaded users and boundary patches require explicit acknowledgements; neighboring terrains are never changed. Authoring refuses native Undo snapshot estimates above 16777216 scalar units. Native Undo is registered; failures use conditional compensation and preserve external writers. Edits mark TerrainData dirty; no global asset save is performed. No terrain creation/resolution change, tree/prototype insertion or whole-terrain dump.

Parameters​

NameTypeRequiredDescription
actionstryesTerrain operation. Use get_region and set_region for grid cells.
targetstryesExisting Terrain GameObject id/name/path.
search_methodLiteral['by_id', 'by_name', 'by_path'] | None—
channelstr | None—Region channel: heights, alphamaps, holes or details.
regiondict[str, Any] | None—Zero-based cell rectangle for get_region and set_region. Read the exact rectangle you intend to change.
valueslist[Any] | None—Replacement values for set_region or set_trees. Region rows are [y][x]. For holes, true means surface and false means a hole.
indiceslist[int] | None—Ordered list of 1 to 64 distinct existing tree indices for get_trees and set_trees.
detail_layerint | None—Existing detail layer index. Required for the details channel and included in the region revision.
indexint | None—Existing TerrainLayer slot for get_layer and set_layer.
layer_pathstr | None—Asset path of the replacement TerrainLayer for set_layer.
layer_guidstr | None—GUID of the replacement asset at layer_path for set_layer.
expected_data_guidstr | None—Required for writes. Copy data.data_guid from the corresponding read of the target.
expected_revisionstr | None—Required for writes. Copy data.revision from the read of the same channel, rectangle and detail layer, ordered tree indices, or layer slot.
allow_shared_databool—
allow_boundarybool—
unity_instancestr | int | None—Target Unity instance for this call: Name@hash or hash prefix; an integer selects only that exact port over stdio and is rejected over HTTP. Read mcpforunity://instances for available targets. Omit to use the legacy active selection or the sole available instance.

Returns​

A dict containing the Unity response. The exact shape depends on the action.

Examples​

To inspect a cell, read a one-cell rectangle. The returned data.values[0][0] is true for surface and false for a hole.

MCP arguments
{
"action": "get_region",
"target": "Terrain",
"search_method": "by_name",
"channel": "holes",
"region": {"x": 4, "y": 9, "width": 1, "height": 1}
}

To restore the surface, send the same target, channel, and region with action="set_region" and values=[[true]]. Set expected_data_guid to the returned data.data_guid and expected_revision to data.revision. Reading a larger rectangle produces a different revision. A fresh read can confirm the surrounding cells afterwards.