Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

TerrainData

Namespace: UnityEngine

/

Inherits from: Object

Description

The TerrainData class stores heightmaps, detail mesh positions, tree instances, and terrain texture alpha maps.

The Terrain component links to the terrain data and renders it.

Variables

alphamapHeightHeight of the alpha map.
alphamapLayersNumber of alpha map layers.
alphamapResolutionResolution of the alpha map.
alphamapWidthWidth of the alpha map.
baseMapResolutionResolution of the base map used for rendering far patches on the terrain.
detailHeightDetail height of the TerrainData.
detailPrototypesContains the detail texture/meshes that the terrain has.
detailResolutionDetail Resolution of the TerrainData.
detailWidthDetail width of the TerrainData.
heightmapHeightHeight of the terrain in samples (Read Only).
heightmapResolutionResolution of the heightmap.
heightmapScaleThe size of each heightmap sample.
heightmapWidthWidth of the terrain in samples (Read Only).
physicMaterialThe physic material used by TerrainCollider using this Terrain.
sizeThe total size in world units of the terrain.
splatPrototypesSplat texture used by the terrain.
treeInstancesContains the current trees placed in the terrain.
treePrototypesThe list of tree prototypes this are the ones available in the inspector.
wavingGrassAmountAmount of waving grass in the terrain.
wavingGrassSpeedSpeed of the waving grass.
wavingGrassStrengthStrength of the waving grass in the terrain.
wavingGrassTintColor of the waving grass that the terrain has.

Functions

GetAlphamapsReturns the alpha map at a position x, y given a width and height.
GetDetailLayerReturns a 2D array of the detail object density in the specific location.
GetHeightGets the height at a certain point x,y.
GetHeightsGet an array of heightmap samples..
GetInterpolatedHeightGets an interpolated height at a point x,y.
GetInterpolatedNormalGet an interpolated normal at a given location.
GetSteepnessGets the gradient of the terrain at point <x,y>.
GetSupportedLayersReturns an array of all supported detail layer indices in the area.
RefreshPrototypesReloads all the values of the available prototypes (ie, detail mesh assets) in the TerrainData Object.
SetAlphamapsAssign all splat values in the given map area.
SetDetailLayerSets the detail layer density map.
SetDetailResolutionSet the resolution of the detail map.
SetHeightsSet an array of heightmap samples.

Inherited members

Variables

hideFlagsShould the object be hidden, saved with the scene or modifiable by the user?
nameThe name of the object.

Functions

GetInstanceIDReturns the instance id of the object.
ToStringReturns the name of the game object.

Static Functions

DestroyRemoves a gameobject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadMakes the object target not be destroyed automatically when loading a new scene.
FindObjectOfTypeReturns the first active loaded object of Type type.
FindObjectsOfTypeReturns a list of all active loaded objects of Type type.
InstantiateClones the object original and returns the clone.

Operators

boolDoes the object exist?
operator !=Compares if two objects refer to a different object.
operator ==Compares if two objects refer to the same.