---
title: PaintLayers(TerrainData, TerrainRegion, ReadOnlySpan<TerrainLayerPaintRule>, TerrainPaintSettings)
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/paintlayers
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unityeditor/terraintools/terraineditutility/paintlayers.md
last_updated: 2026-10-20
generated_at: 2026-11-11T12:59:25.987Z
locale: en-us
---

# PaintLayers(TerrainData, TerrainRegion, ReadOnlySpan<TerrainLayerPaintRule>, TerrainPaintSettings)

> Paints terrain layers inside a region by rules.

## Definition

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

```csharp
public static TerrainEditResult PaintLayers(TerrainData terrainData, TerrainRegion region, ReadOnlySpan<TerrainLayerPaintRule> rules, TerrainPaintSettings settings = null)
```

### Parameters

**** (\[TerrainData]\(/engine/7000.0/script-reference/unityengine/terraindata)): The TerrainData to paint. It must have at least one terrain layer.**** (\[TerrainRegion]\(/engine/7000.0/script-reference/unityeditor/terraintools/terrainregion)): The region to paint.**** (\[ReadOnlySpan\<TerrainLayerPaintRule>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The rules, at least one. To paint a single layer everywhere in the region, pass one rule with that layer index.**** (\[TerrainPaintSettings]\(/engine/7000.0/script-reference/unityeditor/terraintools/terrainpaintsettings)): The blend mode, falloff and dominant layer filter. Null uses the defaults.

### Returns

| Type                                                                                               | Description   |
| -------------------------------------------------------------------------------------------------- | ------------- |
| [TerrainEditResult](/engine/7000.0/script-reference/unityeditor/terraintools/terraineditresult.md) | What changed. |

### Remarks

The rules apply in order to every alphamap texel in the region, and later rules win. A rule applies to a texel when its height and slope lie in the ranges of the rule and, when [TerrainPaintSettings.dominantLayerFilter](/engine/7000.0/script-reference/unityeditor/terraintools/terrainpaintsettings/dominantlayerfilter.md) is set, when its dominant layer before painting is one of the filter layers.

The weights of every texel keep summing to 1 within the alphamap's 8-bit precision: the other layers shrink or grow in proportion to their weights. When the other layers of a texel have no weight, as on a Terrain with a single layer, there is nothing to take weight from: the texel becomes fully the rule's layer whatever the opacity, as with the Paint Texture brush, so a rule cannot lower the only layer of a texel. Texels outside the region are not changed. Call this method on the main thread.
