Scripting in Editor mode : Create a terrain

Hi all!

I’d like to make a GUI window to help me create terrains because I will have a lot of them.

The script would take position data and from there check there isn’t already a terrain there, set resolution, name etc.

Is this possible?

I have tried to use new Terrain and that didn’t work, I also tried to modify an already existing terrain but it seems values are read only…

Any help greatly appreciated!

Valmond

bump

I’m not really sure what you want the script to do. Can you describe it in more detail?

I would like it to create a new Terrain (and set the terrains parameters like position, name, size, resolution etc.).

A bit like clicking on “Terrain” → “Set Resolution” when you are in editor mode except this window would create a new terrain (with preprogrammed parameters and ‘entered’ parameters).

have you looked into the documentation at all, like, say, at Terrain.CreateTerrainGameObject ?

Thanks for the tip, it might be the thing I need.

Anyone knows how to use it? It returns a gameObject that I can’t cast on a Terrain, and TerrainData is still read only so how can I set the size of the terrain?

Any help greatly appreciated

ps. Tom, no need to use that kind of tone when someone doesn’t know something you do, right ;-/

Okay, so I figured out how to get the terrain out of the GameObject cough

In the creation of the new terrain (as the TerrainData has variables that are read only) I took the ‘active terrain’ and used that.
But CreateTerrainGameObject() doesn’t create a new terrain, it just makes an ‘instance’ of the active terrain!

So if I modify the created terrain in the editor it also modifies the original terrain…

Anyone knows of a way how to create a ‘new’ terrain?