how to chande terrain layer texture during runtime,how to change terrain layer diffuse texture in runtime?

My english is bad

So I am making a little farm game in Unity

[171607-未命名.png|171607]

Im trying to change the texture during runtime with C# scripts
( I marked in the picture )

I have search the answer on google

However they did’t fit my need
I dont know how to access the diffuse texture , can someone help me?

This is your answer:

TerrainLayer tlayers = Terrain.activeTerrain.terrainData.terrainLayers;
tlayers[0].diffuseTexture = texture; // = 0 is the first layer in the list of layers / array

greetings