Unity Batch Terrain Creation Script?

Hi all,

I'm new to Unity, but not to programming. I'm just browsing over the API, and can't find the necessary calls to do what I want.

Basically, I want to create a new TerrainData object, set heights, and then set texture, and lightmap (all of which I'm ok on). Here's the thing, I want to do this without creating a terrain object, and want to save the TerrainData object to the Project folder.

Basically, I'm gonna plough through a batch of terrain tiles, and create a TerrainData object for each, then save all these somewhere in the Project folder (preferably the Resources folder).

Any ideas anyone?

Just write an editor script that does this:

Create a game object.

Add a Terrain component to it.

Set stuff with the terrainData property.

"Save" the asset by actually creating a new asset using AssetDatabase.CreateAsset. I don't know what file extension you need to use (it matters!), so just create a Terrain using the editor, and then browse to where it is in your Assets folder on your computer, and see what file extension it is (it might be ".asset" or ".terrain" if I had to guess).

More on extending and scripting for the Unity Editor