Source code for my custom tools tutorial in Unity: https://www.habrador.com/tutorials/editor-scripting/
Notice that the source code is not exactly the same as in the tutorial because it's easier to update the code on GitHub, but the basic idea is the same.
It's kinda boring to add prefabs manually if you have to add many of them, such as when you make a forest. A better way is to make a custom tool where you can add tree prefabs within a circle with just a button click. And if you add too many of them, you can easily remove them with another click.
It's also kinda boring to make a wall manually. A better way is to make another custom tool where you instead of spawning trees within a circle, you spawn wall sections between waypoints.