Why Is The TerrainData.SetHeight So Slow? (Unity)

Why Is The TerrainData.SetHeight So Slow?  (Unity)


  • I want to make our terrain tools run at an interactive speed.


You have implemented some in-house terrain forming tools, but applying any changes to a terrain results in a dramatic drop in performance making them barely usable.


When creating you own terrain editing tools, TerrainData.SetHeights is naturally slower. This is because it needs to recalculate all the terrain LOD information, which is done on every call to SetHeights.

A patch was released for 5.2.0a3 where the SetHeightsDelayedLOD API was introduced to improve the speed at which TerrainData.SetHeights recalculates the LOD information.

In this patch release, the Editor uses two internal functions:

  • SetHeightDelayedLOD()
  • ApplyDelayedHeightmapModification()

With SetHeightDelayedLOD(), the LOD calculation can be skipped or delayed while editing, and is triggered once the mouse button is released.

In interactive editing scenarios, it is advised to call TerrainData.SetHeightsDelayLOD instead, followed by Terrain.ApplyDelayedHeightmapModification when the user completes an editing action.

Was this article helpful?

Related Articles