public static void Flatten(TerrainData terrain, float height)
{
int heightmapWidth = terrain.heightmapWidth;
float[,] heights = new float[terrain.heightmapHeight, heightmapWidth];
for (int i = 0; i < heights.GetLength(0); i++)
{
for (int j = 0; j < heights.GetLength(1); j++)
{
heights[i, j] = height;
}
}
terrain.SetHeights(0, 0, heights);
}