Search Unity

TerrainData access from scripting

Discussion in 'Editor & General Support' started by AliAzin, May 19, 2010.

  1. AliAzin

    AliAzin

    Joined:
    Jun 25, 2009
    Posts:
    51
    Hi,
    Is it possible to change TerrainData through scripting?
    for example is it possible to change the position of trees in editor?

    Thanks
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    The TerrainData class has a limited API. There are some extra functions that are not documented, but these are not officially supported by Unity Tech. You may be able to find details of these on the forums or elsewhere, but you use them at your own risk.
     
  3. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Look in the scripting reference for the Terrain and the TerrainData classes. Specifically the TerrainData.GetHeights and SetHeights allow you to modify the heightmap runtime.

    Notice that due to the amount of computations involved in this, modifying the heights will give you a processing spike - the size of which depends on the size of the terrain.

    Some people are resorting to splitting up their terrain in smaller pieces and chaining them up via SetNeighbor in order to minimize this cost.

    Regarding undocumented API points, a lot of them are available, but do keep in mind that we will change them and thus break your webplayer in future versions.
     
  4. AliAzin

    AliAzin

    Joined:
    Jun 25, 2009
    Posts:
    51
    Thanks for reply ,
    But is there any way to place objects on terrain in editor without painting. for example by giving exact uv coordination?