How to "paint" the terrain in a script?

How can i print a square(texture) on my terrain with a script?
i searched for it but i didn’t found anything helpful…

Projectors, search youtube for unity3d projectors.