# TerrainData access from scripting

**URL:** <https://discussions.unity.com/t/terraindata-access-from-scripting/414084>\
**Category:** Scripting\
**Created:** [May 19, 2010, 8:13am UTC](https://discussions.unity.com/t/terraindata-access-from-scripting/414084 "2010-05-19T08:13:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AliAzin](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/aliazin/32/411058_2.png) [@AliAzin](https://discussions.unity.com/u/AliAzin)\
**Post date:** [May 19, 2010, 8:13am UTC](https://discussions.unity.com/t/terraindata-access-from-scripting/414084/1 "2010-05-19T08:13:54Z")

</div>

Hi,  
Is it possible to change TerrainData through scripting?  
for example is it possible to change the position of trees in editor?

Thanks

---

<div class="post-metadata">

**Author:** ![andeeeee](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@andeeeee](https://discussions.unity.com/u/andeeeee)\
**Post date:** [May 21, 2010, 12:59pm UTC](https://discussions.unity.com/t/terraindata-access-from-scripting/414084/2 "2010-05-21T12:59:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AngryAnt](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/angryant/32/274841_2.png) [@AngryAnt](https://discussions.unity.com/u/AngryAnt)\
**Post date:** [May 21, 2010, 1:05pm UTC](https://discussions.unity.com/t/terraindata-access-from-scripting/414084/3 "2010-05-21T13:05:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AliAzin](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/aliazin/32/411058_2.png) [@AliAzin](https://discussions.unity.com/u/AliAzin)\
**Post date:** [May 22, 2010, 10:41am UTC](https://discussions.unity.com/t/terraindata-access-from-scripting/414084/4 "2010-05-22T10:41:35Z")

</div>

Thanks for reply ,  
But is there any way to place objects on terrain in editor without painting. for example by giving exact uv coordination?
