There is a private method that should draw the ground on the terrain and remove the grass under the building and in a small radius from it. There is already partially written code:
private void SetGroundOnPosition(Vector3 pos, Vector3 size) {
Terrain myTerrain = GameObject.Find("Terrain").GetComponent<Terrain>();
TerrainData terrainData = myTerrain.terrainData;
Vector3 terrainPosition = myTerrain.transform.position;
float[,,] map = new float[myTerrain.terrainData.alphamapWidth, myTerrain.terrainData.alphamapHeight, myTerrain.terrainData.alphamapLayers];;
float[,,] element = new float[Mathf.FloorToInt(size.x), Mathf.FloorToInt(size.z), myTerrain.terrainData.alphamapLayers];
int mapX = (int)(((pos.x - terrainPosition.x) / terrainData.size.x) * terrainData.alphamapWidth);
int mapY = (int)(((pos.z - terrainPosition.z) / terrainData.size.z) * terrainData.alphamapHeight);
map[mapY, mapX, 0] = element[0, 0, 0] = 0;
map[mapY, mapX, 1] = element[0, 0, 1] = 1;
myTerrain.terrainData.SetAlphamaps(mapX, mapY, element);
myTerrain.Flush();
}
But he just draws a bad black fragment under the building. How do I remove the grass under the building and add land under the building? There are no materials about this task anywhere.