---
title: TerrainEditUtility
product: Unity Editor
version: '7000.0'
latest_version: '7000.0'
status: This page documents version 7000.0. The latest version is 7000.0.
canonical: https://docs.unity.com/en-us/engine/7000.0/script-reference/unityeditor/terraintools/terraineditutility
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unityeditor/terraintools/terraineditutility.md
last_updated: 2026-10-20
generated_at: 2026-11-11T16:42:11.369Z
locale: en-us
---

# TerrainEditUtility

> Edits a region of a Terrain on the CPU: change heights and paint layers by rules.

## Definition

* **Type:** Class
* **Namespace:** [UnityEditor.TerrainTools](/engine/7000.0/script-reference/unityeditor/terraintools.md)
* **Assembly:** UnityEditor

```csharp
public static class TerrainEditUtility
```

## Remarks

These methods work on one [TerrainData](/engine/7000.0/script-reference/unityengine/terraindata.md), without a Terrain component or a camera, and do not render anything. Positions are in meters on the X and Z axes of the Terrain's local space (see [TerrainRegion](/engine/7000.0/script-reference/unityeditor/terraintools/terrainregion.md)), heights are in meters above the base of the Terrain, and slopes are in degrees.

Every edit widens its region to cover the cells of the grid it changes, changes nothing outside the region and its blend band, and reports what it changed. An edit that changes something is recorded in the current undo group under the name "Sculpt Terrain Heights" or "Paint Terrain Layers": call [Undo.IncrementCurrentGroup](/engine/7000.0/script-reference/unityeditor/undo/incrementcurrentgroup.md) first to make it an undo step of its own, and [Undo.SetCurrentGroupName](/engine/7000.0/script-reference/unityeditor/undo/setcurrentgroupname.md) afterwards to rename it. An edit that changes nothing writes nothing and records nothing. [TerrainEditUtility.GetHeightmapWeights](/engine/7000.0/script-reference/unityeditor/terraintools/terraineditutility/getheightmapweights.md) and [TerrainEditUtility.GetAlphamapWeights](/engine/7000.0/script-reference/unityeditor/terraintools/terraineditutility/getalphamapweights.md) return the weights an edit of a region applies at each sample or texel, to read the area it covers.

Heights are stored with 16-bit precision (a step of [TerrainData.size](/engine/7000.0/script-reference/unityengine/terraindata/size.md).y / 32766) and layer weights with 8-bit precision, so results are exact only to those steps. Alphamap texel i lies at i \* size / (alphamapResolution - 1), so the edge texels lie on the edges of the Terrain, as the Terrain shaders and [PaintContext](/engine/7000.0/script-reference/unityengine/terraintools/paintcontext.md) sample them.

The methods edit a single Terrain tile and do not blend across neighbors: changing the samples on the edge of a tile opens a seam with its neighbors unless they are edited to match. They do not save the TerrainData asset; the edited TerrainData is marked dirty. If the heightmap was changed on the GPU, for example through [PaintContext](/engine/7000.0/script-reference/unityengine/terraintools/paintcontext.md) or [TerrainData.CopyActiveRenderTextureToHeightmap](/engine/7000.0/script-reference/unityengine/terraindata/copyactiverendertexturetoheightmap.md), call [TerrainData.SyncHeightmap](/engine/7000.0/script-reference/unityengine/terraindata/syncheightmap.md) first, otherwise these methods read, and [TerrainEditUtility.SculptHeights](/engine/7000.0/script-reference/unityeditor/terraintools/terraineditutility/sculptheights.md) overwrites, out-of-date heights.

Each call does all of its work on the main thread and does not limit how long that takes, which can be seconds for a large region of a high-resolution Terrain. In Play mode the changes also persist in the TerrainData asset: to keep the asset unchanged, edit a copy of the TerrainData and assign it to the Terrain and its TerrainCollider.

## Static Methods

| Method                                                                                                                    | Description                                                                          |
| ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| [GetAlphamapWeights](/engine/7000.0/script-reference/unityeditor/terraintools/terraineditutility/getalphamapweights.md)   | Gets the weight that an edit of a region applies at each alphamap texel it covers.   |
| [GetHeightmapWeights](/engine/7000.0/script-reference/unityeditor/terraintools/terraineditutility/getheightmapweights.md) | Gets the weight that an edit of a region applies at each heightmap sample it covers. |
| [PaintLayers](/engine/7000.0/script-reference/unityeditor/terraintools/terraineditutility/paintlayers.md)                 | Paints terrain layers inside a region by rules.                                      |
| [SculptHeights](/engine/7000.0/script-reference/unityeditor/terraintools/terraineditutility/sculptheights.md)             | Changes the heights of a Terrain inside a region.                                    |
