private static void CreateTerrain(MenuCommand menuCommand)
{
TerrainData asset = new TerrainData {
heightmapResolution = 0x401,
size = new Vector3(1000f, 600f, 1000f),
heightmapResolution = 0x200,
baseMapResolution = 0x400
};
asset.SetDetailResolution(0x400, asset.detailResolutionPerPatch);
AssetDatabase.CreateAsset(asset, AssetDatabase.GenerateUniqueAssetPath("Assets/New Terrain.asset"));
GameObject context = menuCommand.context as GameObject;
string uniqueNameForSibling = GameObjectUtility.GetUniqueNameForSibling((context == null) ? null : context.transform, "Terrain");
GameObject child = Terrain.CreateTerrainGameObject(asset);
child.name = uniqueNameForSibling;
GameObjectUtility.SetParentAndAlign(child, context);
Selection.activeObject = child;
Undo.RegisterCreatedObjectUndo(child, "Create terrain");
}