Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


CopyActiveRenderTextureToHeightmap(RectInt, Vector2Int, TerrainHeightmapSyncControl)

Copies the specified part of the active RenderTexture to the Terrain heightmap texture.
Read time 1 minuteLast updated 6 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.TerrainModule
public void CopyActiveRenderTextureToHeightmap(RectInt sourceRect, Vector2Int dest, TerrainHeightmapSyncControl syncControl)

Parameters

sourceRect

The part of the active Render Texture to copy.

The X and Y coordinates of the heightmap texture to copy into.

Controls how CPU synchronization is performed.

Remarks

This functions calls TerrainData.DirtyHeightmapRegion internally and sends out the OnTerrainChanged message accordingly.
The range of expected height values for the active RenderTexture is between
0
and
0.5
. This is unlike TerrainData.SetHeights, which expects height values between
0
and
1
. Additional Resources: TerrainHeightmapSyncControl, TerrainData.DirtyHeightmapRegion, TerrainData.SyncHeightmap.