Loading terrain files dynamically

I am working on a project involving a large open world. My goal right now is to create a manager that knows which terrain file the player is in, and loads the 8 terrain files around that terrain to place one on each side of the player’s current location. The player will be able to roam and not see any terrain updating because the terrains will be larger than the players view distance. I have an idea of the process: create an array of all terrains, determine which terrain the player is on, create another array of all the surrounding terrains plus the current one and load them, unload all terrain files not in the current location array. Actually translating this into c# is a little more difficult. Can anyone point me in the right direction or provide a little bit of insight on this problem?

Look at Terrain.SetNeighbors and after changing/setting those, I think it’s a good idea to do Terrain.Flush() but that might be myth.

If it helps:
http://www.getyour411.com/unoob/terrain1.html

I know that is not what you want to hear, but it’s what stopped me several times, so before you start to worry about the TileManager, you should ask yourself 2 important questions:

1.Are you really able to load a terrain from a file at runtime?
Not just the heightmap, but also splatmaps, alphamaps, treeprototypes and positions, detailprototypes and positions… The terrain doesn’t provide any built in serialization. You need to deserialize that yourself.
And thats just the Terrain. Your game should contain more than terrain, like npcs, buildings and so on. These also need to be loaded.
Hint:I ended up, spending months writing different serializers just to find out, Unity blocks the gamecycle for a few seconds, when its setting heights and alphamaps of a terrain. So the player WILL notice, when your terrain is loading.

2.How do you edit your gamecontent?
As mentioned in 1. you may want to place GameObjects in your world or even worse: Edit your Terrain. If you load your terrain into the editor and manipulate it. You dont manipulate its neighbors, which leads to different heights/alphas at the edges.

Look in the Asset Store for such terrain managers