Documentation

Unity Engine

Download Unity

Unity Engine

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

Paints terrain layers inside a region by rules.
Read time 1 minuteLast updated 22 days ago

Definition

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

Parameters

terrainData

The TerrainData to paint. It must have at least one terrain layer.

The region to paint.

The rules, at least one. To paint a single layer everywhere in the region, pass one rule with that layer index.

The blend mode, falloff and dominant layer filter. Null uses the defaults.

Returns

Type

Description

TerrainEditResultWhat 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 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.