How to select an area of terrain from script during gameplay ?

I have a question for you guys.Consider me as a newbie to unity.
Here’s what I am trying to do.
I have a terrain in my game scene.I wanted to select an area of terrain by mouseclick(or touch) and dragging and do something(example : change the texture of the selected area, change the height etc.) to that selected area.When I click and drag the mouse a rectangular box of any color will appear.
I am trying to do all of the above from scripting and during gameplay. I am using C# for scripting.
How can I achieve this ? Any suggestion or reference will be helpful.

NB: I am able to modify terrain height during gameplay. All I am concern is selecting an area of terrain by mouseclick and dragging during gameplay.

Use raycasting from the mouse/touch, to a layer (the layer is so trees and buildings won’t matter.) That will get you where the corners of the square line up with the terrain. “Unity screen raycast” gives so-so results (why do some many people ask about center of the screen?)

Then drawing the screen rectangle is separate (and not too difficult – maybe a guiTexture.)