Connected textures in 2D

I’m making a procedural map in my 2D topdown game, and I want connected textures for the terrain (so things like the shoreline of the island look nice), however I’m unsure of an efficient (and nice looking) way to do this.

Using Physics2D.OverlapCircle() creates massive walls of text that are hard to debug, and it’s not terribly great for performance.

My basic idea is to have some code that checks what land is nearby, and uses that to pick one of the parts of the image from an array (top left, top middle, top right, bottom left, etc) and then apply that to the SpriteRenderer.

Any ideas?

I’m only 5 years late

but for anyone looking and using unity 2017+, there’s always this: