---
title: GetHeightmapWeights(TerrainData, TerrainRegion, float, out RectInt)
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/getheightmapweights
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unityeditor/terraintools/terraineditutility/getheightmapweights.md
last_updated: 2026-10-20
generated_at: 2026-11-11T15:47:39.288Z
locale: en-us
---

# GetHeightmapWeights(TerrainData, TerrainRegion, float, out RectInt)

> Gets the weight that an edit of a region applies at each heightmap sample it covers.

## Definition

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

## GetHeightmapWeights(TerrainData, TerrainRegion, float, RectInt)

```csharp
public static float[,] GetHeightmapWeights(TerrainData terrainData, TerrainRegion region, float falloff, out RectInt sampleRect)
```

### Parameters

**** (\[TerrainData]\(/engine/7000.0/script-reference/unityengine/terraindata)): The TerrainData whose heightmap grid to use.**** (\[TerrainRegion]\(/engine/7000.0/script-reference/unityeditor/terraintools/terrainregion)): The region.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The fraction of the region, from 0 to 1, over which the weight fades at its edge. See [TerrainRegion.GetWeight](/engine/7000.0/script-reference/unityeditor/terraintools/terrainregion/getweight.md).**** (\[RectInt]\(/engine/7000.0/script-reference/unityengine/rectint)): The rectangle of heightmap samples that the weights cover.

### Returns

| Type                                                               | Description                                                                                                                                                                                    |
| ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [float\[,\]](https://learn.microsoft.com/dotnet/api/system.single) | The weights, from 0 to 1, indexed \[z, x] from the corner of `sampleRect`, as [TerrainData.GetHeights](/engine/7000.0/script-reference/unityengine/terraindata/getheights.md) returns heights. |

### Remarks

These are the weights that [TerrainEditUtility.SculptHeights](/engine/7000.0/script-reference/unityeditor/terraintools/terraineditutility/sculptheights.md) applies with the same falloff and no blend distance: the region is widened to the heightmap cells it crosses in the same way, and sample (x, z) of the heightmap lies at (x, z) \* size / (heightmapResolution - 1). A sample with a weight of 0 lies outside the region. Read the heights of the same rectangle with [TerrainData.GetHeights](/engine/7000.0/script-reference/unityengine/terraindata/getheights.md).
