UnityEditor.HeightmapFilters.Flatten C# (CSharp) Method

Flatten() public static method

public static Flatten ( TerrainData terrain, float height ) : void
terrain UnityEngine.TerrainData
height float
return void
        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);
        }

Usage Example

 void OnWizardCreate()
 {
     Undo.RegisterCompleteObjectUndo(terrainData, "Flatten Heightmap");
     HeightmapFilters.Flatten(terrainData, height / terrainData.size.y);
 }
All Usage Examples Of UnityEditor.HeightmapFilters::Flatten